Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept a Promise for a mongo DB instance? #221

Closed
bttmly opened this issue May 3, 2016 · 2 comments · Fixed by #222
Closed

Accept a Promise for a mongo DB instance? #221

bttmly opened this issue May 3, 2016 · 2 comments · Fixed by #222

Comments

@bttmly
Copy link
Contributor

bttmly commented May 3, 2016

Would you be open to a PR that would accept a promise that resolves to a mongo DB instance? The implementation would probably look something like the following in the constructor:

// ...
} else if (options.dbPromise) {
  dbPromise
    .then(db => this.handleNewConnectionAsync(db))
    .catch(err => this.connectionFailed(err))
}  // ...
@jdesboeufs
Copy link
Owner

Yes!

@Redsandro
Copy link

This would be very much appreciated. In node-mongodb-native 2+ you connect without using a db instance and only have access to the db in a callback. So accepting a promise for the db would prevent us from having to beat around the bush. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants