Abe Miessler
Abe Miessler

Reputation: 85116

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?

Upvotes: 3

Views: 490

Answers (2)

Keith Nicholas
Keith Nicholas

Reputation: 44306

you need this package :-

https://github.com/dburles/mongo-collection-instances

then you can do

Mongo.Collections.getAll()

It gets used in the really useful "Mongol", which allows you to examine your collections / subscriptions on the client side. This tool sounds more like what you are really wanting to achieve

https://github.com/msavin/Mongol

Upvotes: 0

David Weldon
David Weldon

Reputation: 64332

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;
});

Upvotes: 3

Related Questions