Multiple remote database connections to mongodb in meteor


#1

When using db.open(“collectioName”) in meteor for each db operation a new connection is created it even reaches 1000 connections in mongodb for a single user. Is there any way to close connection to database when using db.open(“collectioName”) or open connection to remote databases for each user only once and access collections when needed ?

for each database operation (insert, update, remove) I am using this code to get collection from remote database and insert/edit/delete a doc.

var database = new MongoInternals.RemoteCollectionDriver(mongoUrlUsers 
 + company_id);
Meteor.users.findOne(this.userId).profile.company,
var collection = database.open("system");


collection.insert({
        company: company_id,
        email: data.email,
        mainMobile: userMobile,
        createdAt: new Date(),
        system: true});
  },