Meteor get Collections by Reference

By Tech Writer 1 min read
This short code sample will show you how to get access to a Collection by reference. The root variable is essentially referencing the this global but detects the correct global reference based on where the client is running.
var colData = function (collectionName) {

var root = Meteor.isClient ? window : global;

var col = root[collectionName];

return col.find().fetch();
}
colData('Things');
 
References:
https://dweldon.silvrback.com/collections-by-reference

Related Articles