An open API service indexing awesome lists of open source software.

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

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.