Answers for "mongoose switching database"

0

mongoose switching database

// create a connection to a database
var db = mongoose.createConnection(uri);

// use another database without creating additional connections
var db2 = db.useDb('someDbName');

// proceed as you would normally
var Model1 = db.model('Model1', m1Schema);
var Model2 = db2.model('Model2', m2Schema);
Posted by: Guest on April-20-2021

Browse Popular Code Answers by Language