Answers for "Mongoose and multiple database in single node.js project"

0

Mongoose and multiple database in single node.js project

var conn      = mongoose.createConnection('mongodb://localhost/testA');
var conn2     = mongoose.createConnection('mongodb://localhost/testB');

// stored in 'testA' database
var ModelA    = conn.model('Model', new mongoose.Schema({
  title : { type : String, default : 'model in testA database' }
}));

// stored in 'testB' database
var ModelB    = conn2.model('Model', new mongoose.Schema({
  title : { type : String, default : 'model in testB database' }
}));
Posted by: Guest on April-20-2021

Code answers related to "Mongoose and multiple database in single node.js project"

Browse Popular Code Answers by Language