This package add the mongoose mongodb client to any micro-core application as a multi tenant adaptor
When a customer connects to a micro-core application, the required app_id is passed into the mongoose initializer and used as the database name. Then creating a connection and loading any mongoose models defined in the models directory.
In app/models/example.mongoose.js
const mongoose = require('mongoose');
const ExampleSchema = new mongoose.Schema({
'prop': { 'type': Number, 'required': true },
}, { 'strict': true });
module.exports = mongoose.model('Example', ExampleSchema);
In micro-console
App.connect(app_id, access_token)
.then(App => App.Mongoose.get('Exmaple'))
.then(Example => Example.create({ prop: 42 }))
.then(res => console.log(res))
.catch(err => console.log(err))
In a micro-core
module
module.exports (App) => {
cosnt Example = App.Mongoose.get('Exmaple')
Example.create({ prop: 42 })
}