Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

multiple connections to mongoose

var mongoose = require('mongoose')
var conn = mongoose.createConnection('mongodb://localhost/db1');
var conn2 = mongoose.createConnection('mongodb://localhost/db2');
var Schema = new mongoose.Schema({})
var model1 = conn.model('User', Schema);
var model2 = conn2.model('Item', Schema);
model1.find({}, function() {
   console.log("this will print out last");
});
model2.find({}, function() {
   console.log("this will print out first");
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #multiple #connections #mongoose
ADD COMMENT
Topic
Name
1+9 =