json-schema-models

Data models for mongodb using json schema to define polymorphic schemas to be used with mongodb.
Internally modules use z-schema for json validation and mongodb native driver to connect to db.
Not currently fit for public consumption
API
new jsonSchemaModels(options);
options object must contain the following properties
-
mongo
- name - mongodb name
- url - mongodb url string (host and port)
- options - mongodb connection options
- collections - an array of objects with name, indexes (for createIndexes method) and options properties to pass to mongodb createCollection method
-
schema
- formats - an object with keys being name of format to register and value being the custom function to register for z-schema validation
.addSchemas(schemas)
- method to addSchemas prior to connecting to database, schemas can be an object with keys being records and definitions and the values being key of schema name and value the schema object to loaded
.start(callback)
.stop(callback)
.buildIndexes(callback)
Todo
- Intergrate dropAllIndexes method
- Handle multi-tenant database semantics
- Switch to promises, generators or async await instead of neo-async dependency