3

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?

mc9
  • 6,121
  • 13
  • 49
  • 87

1 Answers1

5

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.

MasterAM
  • 16,283
  • 6
  • 45
  • 66