Suppose I write:
new Meteor.Collection("foos"); new Meteor.Collection("bars");
Is there an API for accessing those collections by name? Something like Meteor.Collection.get(name)
, where name
is "foos"
or "bars"
? I know I could write something like
var MyCollections = { foos: new Meteor.Collection("foos"); bars: new Meteor.Collection("bars"); }
and then use MyCollections[name]
, but I'd prefer to use an existing API if one exists.
Based on Shane Donelley's mongoinspector https://github.com/shanedonnelly1/mongoinspector
getCollection = function (string) { for (var globalObject in window) { if (window[globalObject] instanceof Meteor.Collection) { if (globalObject === string) { return (window[globalObject]); break; }; } } return undefined; // if none of the collections match };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With