mount the directory into an alias
npm install --save kenote-mount
// mounts
const path = require('path')
const { mounts } = require('kenote-mount')
const { userProxy, bookProxy } = mounts(path.resolve(__dirname, 'proxys'), 'Proxy')
userProxy.login(...)
bookProxy.find(...)
// loadModel
const mongoose = require('mongoose')
const MongooseDao = require('mongoosedao')
const { loadModel } = require('kenote-mount')
const Schema = mongoose.Schema
function getMongooseDao (definition, name) {
let schema = new Schema(definition)
let model = mongoose.model(name, schema)
return new MongooseDao(model)
}
module.exports = loadModel(__dirname, getMongooseDao)
this repo is released under the MIT License.