New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-models

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-models - npm Package Compare versions

Comparing version 0.5.6 to 0.6.0

65

lib/index.js

@@ -56,32 +56,35 @@ 'use strict';

if (compileErr) {
return cb(compileErr);
return cb(compileErr, null);
}
if (!Object.keys(this.schema.records).length) {
return cb('No record schemas loaded, please use addSchemas to add schema definitions');
return cb('No record schemas loaded, please use addSchemas to add schema definitions', null);
}
return this.validate(this.schema, (err) => {
this.validate(this.schema, (err) => {
if (err) {
return cb(err);
return cb(err, null);
}
const conn = internals.prepareConnection(this.settings.mongo);
return MongoClient.connect(conn.url, conn.options, (err, db) => {
MongoClient.connect(conn.url, conn.options, (err, db) => {
if (err) {
return cb(err);
return cb(err, null);
}
this.db = db;
return this.createCollections((err, collections) => {
this.createCollections((err, collections) => {
if (err) {
return cb(err);
return cb(err, null);
}
return this.createSchemas(db, (err, schemas) => {
this.createSchemas(db, (err, schemas) => {
if (err) {
return cb(err);
return cb(err, null);
}
const definitions = schemas.definitions;

@@ -137,3 +140,3 @@ const records = schemas.records;

}
return callback();
return callback(null);

@@ -158,2 +161,3 @@ };

}
this.db.close();

@@ -166,12 +170,13 @@ return null;

const collections = this.collections;
Async.eachSeries(collections, (collection, next) => {
const collectionName = collection.name;
const iterator = (collection, next) => {
const name = collection.name;
const indexes = collection.indexes;
Async.eachSeries(indexes, (index, done) => {
const createIndexes = (index, done) => {
this.db.createIndex(collectionName, index.key, index.options, (err, res) => {
this.db.createIndex(name, index.key, index.options, (err, res) => {
if (err) {
return done('Cannot create collection indices: ' + collectionName + ' - ' + err);
return done('Cannot create collection indices: ' + collection.name + ' - ' + err);
}

@@ -181,10 +186,18 @@ return done();

}, (err) => {
};
Async.eachSeries(indexes, createIndexes, (err) => {
return next(err);
});
}, (err) => {
};
Async.eachSeries(collections, iterator, (err) => {
return callback(err);
});
};

@@ -196,9 +209,10 @@

const collections = {};
Async.eachSeries(rawCollections, (rawCollection, next) => {
const collectionName = rawCollection.name;
const iterator = (item, next) => {
const collectionName = item.name;
this._collectionNames.push(collectionName);
const options = rawCollection.options;
const options = item.options;
return this.db.createCollection(collectionName, options, (err, collection) => {
this.db.createCollection(collectionName, options, (err, collection) => {

@@ -208,2 +222,3 @@ if (err) {

}
collections[collectionName] = collection;

@@ -213,7 +228,9 @@ return next();

});
};
}, (err) => {
Async.eachSeries(rawCollections, iterator, (err) => {
return callback(err, collections);
});
};

@@ -267,3 +284,3 @@

const url = connection.url + '/' + connection.name;
const url = `${connection.url}/${connection.name}`;
return {

@@ -270,0 +287,0 @@ name: connection.name,

{
"name": "json-schema-models",
"version": "0.5.6",
"version": "0.6.0",
"description": "json schema based models",

@@ -8,3 +8,4 @@ "main": "lib/index.js",

"pretest": "mongo localhost:27017/wadofgum_db ./scripts/mongo.js",
"test": "lab -a code -v -t 100 -L"
"test": "lab -a code -v -t 100 -L",
"coveralls": "lab -r lcov | coveralls"
},

@@ -21,17 +22,17 @@ "engines": {

"dependencies": {
"basic-utils": "^1.1.0",
"hoek": "^3.0.1",
"joi": "^7.0.1",
"mongodb": "^2.1.0",
"hoek": "^4.0.0",
"joi": "^8.4.0",
"mongodb": "^2.1.21",
"neo-async": "^1.7.1",
"wadofgum": "^4.1.0",
"wadofgum-json-schema": "^0.4.1",
"wadofgum-mongodb": "^0.4.0",
"yajsv": "^0.6.1",
"wadofgum": "^5.1.0",
"wadofgum-json-schema": "^1.1.1",
"wadofgum-mongodb": "^1.1.1",
"yajsv": "^0.7.0",
"z-schema": "^3.16.1"
},
"devDependencies": {
"code": "^2.0.1",
"lab": "^8.0.0"
"code": "^3.0.0",
"coveralls": "^2.11.9",
"lab": "^10.7.1"
}
}

@@ -1,2 +0,4 @@

# json-schema-models [![build status](https://travis-ci.org/simon-p-r/json-schema-models.svg?branch=master)](https://travis-ci.org/simon-p-r/json-schema-models)
# json-schema-models
[![build status](https://travis-ci.org/simon-p-r/json-schema-models.svg?branch=master)](https://travis-ci.org/simon-p-r/json-schema-models)
[![Coverage Status](https://coveralls.io/repos/github/simon-p-r/json-schema-models/badge.svg?branch=master)](https://coveralls.io/github/simon-p-r/json-schema-models?branch=master)

@@ -27,4 +29,4 @@ Data models for mongodb using json schema to define polymorphic schemas to be used with mongodb.

##### .start(callback)

@@ -31,0 +33,0 @@

@@ -6,3 +6,2 @@ 'use strict';

db.example.dropIndexes();
print('Creating index');
db.dropDatabase();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc