mongoose-global
v1.0.1
Published
Global mongoose instance
Downloads
34
Readme
Global mongoose instance
Installation
npm i --save mongoose-global
Usage
const {mongoose} = require('mongoose-global');
// or
const mongoose = require('mongoose-global')();
// or
const mongoose = require('mongoose-global')(dbURI);
// or
const mongoose = require('mongoose-global').connect(dbURI);
// or
const connectDb = require('mongoose-global');
const mongoose = connectDb(dbURI, options);
You need to connect only once. Then you can just require mongoose anywhere and use.
New connection logic is used with native promises and useMongoClient
option.