Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mjlescano/mongoose-connection-ready

Promisified mongoose connection state.
https://github.com/mjlescano/mongoose-connection-ready

Last synced: 9 days ago
JSON representation

Promisified mongoose connection state.

Awesome Lists containing this project

README

        

Mongoose Connection Ready
=========================

Helper function to get a Promise from a Mongoose `connection` object.

Usage
=====

```
npm install mongoose-connection-ready --save
```

```javascript
var mongoose = require('mongoose')
var connReady = require('mongoose-connection-ready')

mongoose.connect('mongodb://localhost/dev')

connReady(mongoose.connection)
.then(function () {
console.log('Mongo connected successfully!')
})
.catch(function () {
console.error('Couldn\'t connect to Mongo.')
mongoose.connection.close(function () {
process.exit(1)
})
})
```