Search code examples
meteorminimongo

Possible to find all client side collections from the console?


I have a meteor.js application and I would like to take a look at what information is included in all client side collections. There are about 20 client side collections and I know that I can access them one by one and have them return their documents like so:

Meteor.myCollection.find().fetch()

But I'm wondering if there is a way to get all meteor.js collections that are on the client side and loop through them. Can anyone suggest a way to do this?


Solution

  • To get the collection instances:

    var collections = _.chain(_.keys(window))
      .filter(function(k) {return window[k] instanceof Meteor.Collection;})
      .map(function(k) {return window[k];})
      .value();
    

    To get the collection names:

    var names = _.filter(_.keys(window), function(key) {
      return window[key] instanceof Meteor.Collection;
    });