Reputation: 4407
I tried to use:
MongoInternals.defaultRemoteCollectionDriver().mongo.db.listCollections()
in order to get all collection names in meteor database, but it returns a very long JSON, in which i couldn't find the pure collection names. (see the attached image)
How can I get meteor collection names in a following format:
["test1", "test2", "users"...]
Upvotes: 4
Views: 1135
Reputation: 4407
Ok, here is the working code, thanks @PaulS.
db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
collections = db.listCollections();
collections.each(function(n, collection){
if(collection){
console.log( collection.name );
}
});
Upvotes: 8