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.
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
- 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
-
method to validate the schemas
- 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 and each collection created.
-
method to close connections and clean-up for server closedown
- optional callback with no signature
-
method to build indexes based on schema definitions
- callback with err signature
- Intergrate dropAllIndexes method
- Handle multi-tenant database semantics
- Switch to promises, generators or async await instead of neo-async dependency