I am trying to make a multi-tenant application in MEAN, based on value of some variable it should pick a mongoDB Connection form pool of connections and do CURD Operations on a collection.
var mongoose = require('mongoose');
var connectionPool = {};
connectionPool['dbName1'] = mongoose.createConnection('mongodb://localhost/database1');
connectionPool['dbName2'] = mongoose.createConnection('mongodb://localhost/database2');
connectionPool['dbName3'] = mongoose.createConnection('mongodb://localhost/database3');
The issue is connection object when used to do CURD operation is not working.
Error - db.collection(...).find(...).exec is not a function
Thanks.