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

Connection pool sharing #1601

Closed
wants to merge 4 commits into from

Conversation

ebensing
Copy link
Contributor

This allows you to connect to multiple databases using the same connection pool. See #1124.

Create a new database off of the existing connection object.

var db = mongoose.createConnection(uri);
var db2 = db.openNewDb('someDbName');
// define models like you would normally
var Model1 = db.model('Model1', m1Schema);
var Model2 = db2.model('Model2', m2Schema);

ebensing added 3 commits July 29, 2013 13:05
This should allow users to share their connection pools with fairly
neat semantics and relative ease-of-use.
This seems to work and passes all of the test cases. Might be slight
issues related to events, but they all seem to be functioning properly
// we have to call onOpen. This is the best way I can figure out how to do
// that
this.db.once('open', function () {
newConn.onOpen();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this.db has already opened?

Also, added a lot more test coverage for all of the different events.
refactored one test that wasn't checking a value that would guarantee
correctness.
@ebensing
Copy link
Contributor Author

ebensing commented Aug 7, 2013

I have not added tests for reconnected because that isn't even working on a single connection right now. Also, error and fullsetup don't have tests yet, unsure if they needed them (side note: how do you force an error?)

@aheckmann
Copy link
Collaborator

merged!

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 this pull request may close these issues.

2 participants