https://github.com/doasync/mongoose-global
Global instance of mongoose with new connection logic
https://github.com/doasync/mongoose-global
Last synced: 12 months ago
JSON representation
Global instance of mongoose with new connection logic
- Host: GitHub
- URL: https://github.com/doasync/mongoose-global
- Owner: doasync
- License: mit
- Created: 2017-08-04T18:43:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T21:58:31.000Z (about 3 years ago)
- Last Synced: 2025-03-20T20:37:44.430Z (12 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Global mongoose instance
===================
Installation
-------------
```bash
npm i --save mongoose-global
```
Usage
-------------------
```javascript
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.