Skip to content

Instantly share code, notes, and snippets.

@stephentcannon
Created February 13, 2014 19:11
Show Gist options
  • Save stephentcannon/8981744 to your computer and use it in GitHub Desktop.
Save stephentcannon/8981744 to your computer and use it in GitHub Desktop.
when is meteor collection find firing?
var wrappedFind = Meteor.Collection.prototype.find;
Meteor.Collection.prototype.find = function () {
var cursor = wrappedFind.apply(this, arguments);
var collectionName = this._name;
cursor.observeChanges({
added: function (id, fields) {
console.log(collectionName, 'added', id, fields);
},
changed: function (id, fields) {
console.log(collectionName, 'changed', id, fields);
},
movedBefore: function (id, before) {
console.log(collectionName, 'movedBefore', id, before);
},
removed: function (id) {
console.log(collectionName, 'removed', id);
}
});
return cursor;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment