MongoInternals.RemoteCollectionDriver("mongodb://#{server.ip}:#{server.port}/#{server.dbName}")
If I call several remote MongoDB methods, and if there are identical names, Meteor throws an error something like this: "collectionName / insert already exists ..."
I think Meteor creates each collection method internally to manage each collection, but I need to control several MongoDBs at a time for some reason.
How can I avoid this situation?
Also, I understand that I can use the Npm Mongo driver directly, without using the NPM package.
var MongoClient = MongoInternals.NpmModules.mongodb.module.MongoClient;
var url = 'mongodb://localhost:27017/myproject';
MongoClient.connect(url, function(err, db) {
console.log("Connected correctly to server");
try {
var collection = db.collection('documents');
collection.find({}).toArray(function(err, docs){
console.log(err);
console.log(docs);
});
}
catch(err) {
console.log(err);
}
db.close();
});
But it still makes me control every DB using the Node.js. callback style Is there any idea to avoid this?
source
share