json-schema-models
Advanced tools
Comparing version 0.0.1 to 0.0.2
200
lib/index.js
'use strict'; | ||
// Load modules | ||
var Async = require('neo-async'); | ||
@@ -8,104 +7,162 @@ var MongoClient = require('mongodb').MongoClient; | ||
var Joi = require('joi'); | ||
var Collection = require('./collection.js'); | ||
var Record = require('./record.js'); | ||
var Yajsv = require('yajsv'); | ||
var internals = { | ||
Schema: { | ||
name: Joi.string().required(), | ||
url: Joi.string().required(), | ||
options: Joi.object() | ||
} | ||
}; | ||
options: Joi.object({ | ||
mongo: Joi.object({ | ||
name: Joi.string().required(), | ||
url: Joi.string().required(), | ||
options: Joi.object() | ||
}), | ||
schema: Joi.object({ | ||
formats: Joi.object({ | ||
}).pattern(/^[a-zA-Z]+$/, Joi.func().required()) | ||
}).required(), | ||
validator: Joi.object().required() | ||
}) | ||
module.exports = internals.Manager = function (options) { | ||
Hoek.assert(this instanceof internals.Manager, 'ModelManager must be created using new'); | ||
Hoek.assert(typeof options === 'object', 'options must be an object'); | ||
this.settings = options; | ||
var result = Joi.validate(this.settings, internals.Schema); | ||
if (result.error) { | ||
throw result.error; | ||
}; | ||
this.schema = null; | ||
this.db = null; | ||
this.models = {}; | ||
return this; | ||
}; | ||
internals.Manager.prototype.start = function (schema, callback) { | ||
module.exports = internals.Datastore = class Datastore { | ||
var self = this; | ||
internals.schema = schema; | ||
var conn = internals.prepareConnection(this.settings); | ||
MongoClient.connect(conn.url, conn.options, function (err, db) { | ||
constructor (options) { | ||
if (err) { | ||
return callback(err, null); | ||
Hoek.assert(typeof options === 'object', 'Datastore must be constructed with a valid options object'); | ||
this.settings = options; | ||
var result = Joi.validate(this.settings, internals.options); | ||
if (result.error) { | ||
throw result.error; | ||
}; | ||
this.schema = new Yajsv(this.settings.schema); | ||
this.validator = this.settings.validator; | ||
this.db = null; | ||
this.records = {}; | ||
} | ||
start (callback) { | ||
var self = this; | ||
try { | ||
this.schema.compile(); | ||
} catch (e) { | ||
return callback(e, null); | ||
} | ||
self.db = db; | ||
internals.schema.db = db; | ||
var models = internals.schema.models; | ||
for (var i = 0, il = models.length; i < il; ++i) { | ||
var name = models[i].alias || models[i].collectionName; | ||
self.models[name] = new Collection(db, internals.schema, name); | ||
} | ||
return callback(null, { | ||
models: self.models, | ||
db: db | ||
this.schema.validator = this.validator; | ||
var conn = internals.prepareConnection(this.settings.mongo); | ||
return this.validate(this.schema, function (err, valid) { | ||
if (err) { | ||
return callback(err, null); | ||
} | ||
MongoClient.connect(conn.url, conn.options, function (err, db) { | ||
if (err) { | ||
return callback(err, null); | ||
} | ||
self.db = db; | ||
var records = Object.keys(self.schema.records); | ||
for (var i = 0, il = records.length; i < il; ++i) { | ||
var name = records[i]; | ||
self.records[name] = new Record(db, self.schema, name); | ||
} | ||
return callback(null, { | ||
records: self.records, | ||
db: db | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
}; | ||
validate (rawSchemas, callback) { | ||
var err, schemaName, valid; | ||
var defs = Object.keys(rawSchemas.definitions); | ||
for (var i = 0, il = defs.length; i < il; ++i) { | ||
internals.Manager.prototype.stop = function (callback) { | ||
schemaName = defs[i]; | ||
var definition = rawSchemas.definitions[schemaName].schema; | ||
valid = this.validator.validateSchema(definition); | ||
if (callback) { | ||
if (!valid) { | ||
err = { | ||
schemaName, | ||
msg: this.validator.getLastError() | ||
}; | ||
return callback(err, null); | ||
} | ||
} | ||
var recs = Object.keys(rawSchemas.records); | ||
for (var a = 0, al = recs.length; a < al; ++a) { | ||
schemaName = recs[a]; | ||
var record = rawSchemas.records[schemaName].schema; | ||
valid = this.validator.validateSchema(record); | ||
if (!valid) { | ||
err = { | ||
schemaName, | ||
msg: this.validator.getLastError() | ||
}; | ||
return callback(err, null); | ||
} | ||
} | ||
return callback(null, true); | ||
} | ||
stop (callback) { | ||
if (callback) { | ||
delete this.collections; | ||
return this.db.close(callback); | ||
} | ||
delete this.collections; | ||
return this.db.close(callback); | ||
this.db.close(); | ||
return; | ||
} | ||
delete this.collections; | ||
this.db.close(); | ||
return; | ||
}; | ||
buildIndexes (callback) { | ||
internals.Manager.prototype.buildIndexes = function (callback) { | ||
var self = this; | ||
var records = this.schema.records; | ||
var retVal = {}; | ||
Async.eachSeries(records, function (record, next) { | ||
var self = this; | ||
var models = internals.schema.models; | ||
var retVal = {}; | ||
Async.eachSeries(models, function (model, next) { | ||
var recName = record.metaSchema.name; | ||
var collectionName = record.metaSchema.base || recName; | ||
var indexes = self.records[recName].indexes; | ||
Async.eachSeries(indexes, function (index, done) { | ||
var collectionName = model.collectionName; | ||
var modelName = model.alias || collectionName; | ||
var indexes = self.models[modelName].indexes; | ||
Async.eachSeries(indexes, function (index, done) { | ||
self.db.createIndex(collectionName, index.key, index.options, function (err, res) { | ||
self.db.createIndex(collectionName, index.key, index.options, function (err, res) { | ||
if (err) { | ||
return done('Cannot create collection indices: ' + collectionName + ' - ' + err, null); | ||
} | ||
retVal[record] = res; | ||
return done(null); | ||
}); | ||
}, function (err) { | ||
if (err) { | ||
return done('Cannot create collection indices: ' + collectionName + ' - ' + err, null); | ||
return next(err); | ||
} | ||
retVal[model] = res; | ||
return done(null); | ||
return next(); | ||
}); | ||
}, function (err) { | ||
if (err) { | ||
return next(err); | ||
return callback(err, null); | ||
} | ||
return next(); | ||
return callback(null, retVal); | ||
}); | ||
}, function (err) { | ||
if (err) { | ||
return callback(err, null); | ||
} | ||
return callback(null, retVal); | ||
}); | ||
} | ||
}; | ||
@@ -120,6 +177,5 @@ | ||
url: url, | ||
options: connection.options, | ||
schemas: connection.schemas | ||
options: connection.options | ||
}; | ||
}; |
{ | ||
"name": "json-schema-models", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "json schema based models", | ||
@@ -10,2 +10,9 @@ "main": "lib/index.js", | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:simon-p-r/json-schema-models.git" | ||
}, | ||
"author": "simon-p-r <simon.ricaldone@circabs.com> (https://github.com/simon-p-r)", | ||
@@ -17,3 +24,4 @@ "license": "BSD-3-Clause", | ||
"mongodb": "2.x.x", | ||
"neo-async": "1.x.x" | ||
"neo-async": "1.x.x", | ||
"yajsv": "^0.3.0" | ||
}, | ||
@@ -23,4 +31,4 @@ "devDependencies": { | ||
"lab": "6.x.x", | ||
"yajsv": "0.x.x" | ||
"z-schema": "^3.15.3" | ||
} | ||
} |
@@ -14,12 +14,16 @@ # 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) | ||
options object must contain the following properties | ||
+ name - mongodb name | ||
+ url - mongodb url string (host and port) | ||
+ options - mongodb connection options | ||
+ mongo | ||
+ name - mongodb name | ||
+ url - mongodb url string (host and port) | ||
+ options - mongodb connection options | ||
##### .start(yajsv, callback) | ||
+ schema | ||
+ formats - an object with keys being name of format to register and value being the custom function to register for z-schema validation | ||
+ validator - an object created by z-schema constructor function | ||
##### .start(callback) | ||
+ method to validate the schemas | ||
##### params | ||
+ yajsv object constructed by [yajsv](https://github.com/simon-p-r/yajsv) module, required for internal validation and defines what models to build | ||
+ callback with error, result signature - error will show if any schemas have failed validation and result is an object containing the raw mognodb db handle from connection and an object containing handles to each model with keys beign name of model and value being the handle. | ||
@@ -43,7 +47,7 @@ | ||
Intergrate with yasjv properly | ||
Add validation to model insert, insertMany and update methods | ||
Add lifecycle hooks for methods that are defined within defined schemas | ||
Intergrate dropAllIndexes method | ||
Handle multiple schema and database namespaces | ||
Switch to generators or async await instead of neo-async dependency | ||
+ Add json-schema validation to model insert, insertMany and update methods | ||
+ Add lifecycle hooks for methods that are defined on schema definitions | ||
+ Intergrate dropAllIndexes method | ||
+ Handle multi-tenant database semantics | ||
+ Switch to generators or async await instead of neo-async dependency | ||
+ Add ability to use different datastores based on configuration |
print('Mongo version', version()); | ||
print('Dropping old indexes'); | ||
db.dummy.dropIndexes(); | ||
db.example.dropIndexes(); | ||
db.rec.dropIndexes(); | ||
print('Creating index'); | ||
db.example.createIndex({ test: 1 }, { unique: true, background: true, w: 1 }); | ||
db.dummy.createIndex({ test: 1 }, { unique: true, background: true, w: 1 }); |
@@ -1,2 +0,2 @@ | ||
// Load modules | ||
'use strict'; | ||
@@ -8,3 +8,3 @@ module.exports = { | ||
description: 'dummy collection', | ||
type: 'collection', | ||
type: 'record', | ||
jsonSchema: 'v4', | ||
@@ -11,0 +11,0 @@ name: 'dummy', |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
module.exports = { | ||
@@ -2,0 +4,0 @@ |
@@ -1,6 +0,8 @@ | ||
// Load modules | ||
'use strict'; | ||
var Dummy = require('./dummy.js'); | ||
var Example = require('./example.js'); | ||
var Invalid = require('./invalid.js'); | ||
var Rec = require('./rec.js'); | ||
var Sample = require('./sample.js'); | ||
@@ -11,4 +13,6 @@ module.exports = [ | ||
Example, | ||
Rec | ||
Invalid, | ||
Rec, | ||
Sample | ||
]; |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
module.exports = { | ||
@@ -8,3 +10,2 @@ | ||
jsonSchema: 'v4', | ||
base: 'dummy', | ||
name: 'rec', | ||
@@ -15,3 +16,3 @@ version: 1, | ||
flds: { | ||
'test': 1 | ||
'tdid': 1 | ||
} | ||
@@ -23,3 +24,2 @@ }] | ||
id: 'rec', | ||
type: 'object', | ||
@@ -32,3 +32,4 @@ additionalProperties: false, | ||
maxLength: 50 | ||
} | ||
}, | ||
'$ref.control': 'sample' | ||
}, | ||
@@ -35,0 +36,0 @@ required: ['lookup'] |
@@ -5,3 +5,2 @@ // Load modules | ||
var Lab = require('lab'); | ||
var Schema = require('yajsv'); | ||
var Manager = require('../lib/index.js'); | ||
@@ -11,8 +10,11 @@ | ||
var Schemas = require('./fixtures/schemas/index.js'); | ||
// var AddedSchemas = require('./fixtures/schemas/array.js'); | ||
// var FormatSchemas = require('./fixtures/schemas/formats.js'); | ||
// var Formats = require('./fixtures/formats.js'); | ||
var Formats = require('./fixtures/formats.js'); | ||
var InvalidDef = require('./fixtures/schemas/invalid/def.js'); | ||
var InvalidRec = require('./fixtures/schemas/invalid/rec.js'); | ||
var InvalidRef = require('./fixtures/schemas/invalid/ref.js'); | ||
var Rec = require('./fixtures/data/rec.json'); | ||
var Rec1 = require('./fixtures/data/rec1.json'); | ||
var Rec2 = require('./fixtures/data/rec2.json'); | ||
var ZSchema = require('z-schema'); | ||
var Validator = new ZSchema(); | ||
@@ -28,12 +30,2 @@ // Set-up lab | ||
it('should throw an error when constructed without new', function (done) { | ||
expect(function () { | ||
Manager(); | ||
}).throws(Error); | ||
done(); | ||
}); | ||
it('should throw an error when constructed without an options object', function (done) { | ||
@@ -44,3 +36,3 @@ | ||
new Manager(); | ||
}).throws(Error, 'options must be an object'); | ||
}).throws(Error, 'Datastore must be constructed with a valid options object'); | ||
done(); | ||
@@ -52,13 +44,17 @@ | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27018', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27018', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
@@ -87,24 +83,102 @@ expect(err).to.exist(); | ||
it('should return an error when a defintion schema is not valid with z-schema', function (done) { | ||
var manager = new Manager({ | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
manager.schema.addSchemas([InvalidDef]); | ||
manager.start(function (err, result) { | ||
expect(err).to.exist(); | ||
done(); | ||
}); | ||
}); | ||
it('should return an error from start method when a schema compile throws an error', function (done) { | ||
var manager = new Manager({ | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
manager.schema.addSchemas([InvalidRef]); | ||
manager.start(function (err, result) { | ||
expect(err).to.exist(); | ||
done(); | ||
}); | ||
}); | ||
it('should return an error from start method when a record schema is not valid with z-schema', function (done) { | ||
var manager = new Manager({ | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
manager.schema.addSchemas([InvalidRec]); | ||
manager.start(function (err, result) { | ||
expect(err).to.exist(); | ||
done(); | ||
}); | ||
}); | ||
it('should create settings object from options passed to constructor and connect to db', function (done) { | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
manager.start(schema, function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
expect(result.db).to.exist(); | ||
expect(result.models).to.exist(); | ||
expect(result.models.dummy).to.exist(); | ||
expect(result.models.rec).to.exist(); | ||
expect(result.records).to.exist(); | ||
expect(result.records.rec).to.exist(); | ||
expect(manager.db).to.exist(); | ||
@@ -119,26 +193,25 @@ manager.stop(done); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
manager.start(schema, function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
var dummy = result.models.dummy; | ||
expect(dummy).to.be.an.object(); | ||
dummy.insertMany([Rec1, Rec2], {}, function (err, rec) { | ||
result.records.rec.insertMany([Rec1, Rec2], {}, function (err, rec) { | ||
expect(err).to.not.exist(); | ||
expect(rec).to.be.an.object(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -150,22 +223,21 @@ }); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
manager.start(schema, function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
var dummy = result.models.dummy; | ||
expect(dummy).to.be.an.object(); | ||
dummy.insertOne(Rec, {}, function (err, rec) { | ||
result.records.rec.insertOne(Rec, {}, function (err, rec) { | ||
@@ -182,20 +254,22 @@ expect(err).to.not.exist(); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
result.records.rec.count({}, {}, function (err, rec) { | ||
result.models.dummy.count({}, {}, function (err, rec) { | ||
expect(err).to.not.exist(); | ||
@@ -211,23 +285,25 @@ expect(rec).to.be.a.number(); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
result.models.dummy.find({}, function (err, rec) { | ||
result.records.rec.find({}, function (err, rec) { | ||
expect(err).to.not.exist(); | ||
expect(rec).to.be.an.array(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -239,23 +315,26 @@ }); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
result.models.dummy.findOne({ tdid: 'test' }, {}, function (err, rec) { | ||
result.records.rec.findOne({ tdid: 'test' }, {}, function (err, rec) { | ||
expect(err).to.not.exist(); | ||
expect(rec).to.be.an.object(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -267,23 +346,25 @@ }); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
result.models.dummy.deleteMany({}, {}, function (err, rec) { | ||
result.records.rec.deleteMany({}, {}, function (err, rec) { | ||
expect(err).to.not.exist(); | ||
expect(rec).to.be.an.object(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -295,23 +376,25 @@ }); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
expect(err).not.to.exist(); | ||
expect(result).to.be.an.object(); | ||
result.models.dummy.deleteOne({}, {}, function (err, rec) { | ||
result.records.rec.deleteOne({}, {}, function (err, rec) { | ||
expect(err).to.not.exist(); | ||
expect(rec).to.be.an.object(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -323,14 +406,18 @@ }); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
@@ -342,4 +429,3 @@ expect(err).not.to.exist(); | ||
expect(rec).to.be.exist(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -351,17 +437,21 @@ }); | ||
var schema = new Schema({}); | ||
var manager = new Manager({ | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
mongo: { | ||
name: 'test_db', | ||
url: 'mongodb://localhost:27017', | ||
options: { | ||
} | ||
} | ||
}, | ||
schema: { | ||
formats: Formats | ||
}, | ||
validator: Validator | ||
}); | ||
schema.addSchemas(Schemas); | ||
schema.compile(); | ||
manager.start(schema, function (err, result) { | ||
manager.schema.addSchemas(Schemas); | ||
manager.start(function (err, result) { | ||
expect(err).not.to.exist(); | ||
manager.models.example.indexes = [{ | ||
manager.records.dummy.indexes = [{ | ||
key: { | ||
@@ -379,4 +469,3 @@ test: 1 | ||
expect(rec).to.not.exist(); | ||
manager.stop(); | ||
done(); | ||
manager.stop(done); | ||
}); | ||
@@ -383,0 +472,0 @@ }); |
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
29848
21
858
52
0
5
+ Addedyajsv@^0.3.0
+ Addedbasic-utils@0.0.1(transitive)
+ Addedbossy@2.0.1(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddeepmerge@0.2.10(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
+ Addedrequire-plus@1.5.0(transitive)
+ Addedvalidator@10.11.0(transitive)
+ Addedyajsv@0.3.9(transitive)
+ Addedz-schema@3.25.1(transitive)