@ydv/mongo
npm install --save @ydv/mongo
Exports db helpers and mongoose.
Expects process.env.MONGO_URL to be set for connection!!
const { db, Types, Model, Schema } = require('@ydv/mongo)
db; // db is just a copy of require('mongoose')
Types; // shorthand for mongoose.Schema.Types.
// e.g. Types.ObjectId === mongoose.Schema.Types.ObjectId.
Model; // wrapper to create a mongoose model with some defaults/fixes for Lambda.
Schema; // wrapper to create a mongoose Schema with some defaults.
Find method in Model class is redifined so that all the find queries return a result equivaluent to find(args).lean().