mc9
mc9

Reputation: 6341

View all collections in the browser console

I would like to know how to list all collections of Meteor app in a browser.

Basically, I need to use an undocumented DDP connection to some host, and need to know all collection names.

I'ved tried things like Meteor.collections, Meteor.default_connection.collections but none of them works. Any suggestions?

Upvotes: 3

Views: 1539

Answers (1)

MasterAM
MasterAM

Reputation: 16488

Mongo's local_collection_driver updates an object on DDP the connection whenever a collection is created. It can be accessed via <connection>._mongo_livedata_collections, and its keys are the names of the collections.

_.keys(Meteor.connection._mongo_livedata_collections)

The DDP connection itself manages its stores in an object called _stores, and can be accessed similarly via:

_.keys(Meteor.connection._stores)

This API is, however, private and undocumented, and may change in the future. A cleaner way would be to use a package that provides such function: dburles:mongo-collection-instances.

Then, use Mongo.Collection.getAll() to get a description of all of the collections, which includes their names.

Upvotes: 5

Related Questions