Skip to content

Instantly share code, notes, and snippets.

@RANUX
Last active October 30, 2016 20:46
Show Gist options
  • Save RANUX/0f13dd93e34b2f12194f38bd8cb6cb07 to your computer and use it in GitHub Desktop.
Save RANUX/0f13dd93e34b2f12194f38bd8cb6cb07 to your computer and use it in GitHub Desktop.
Meteor and mongo queries examples
// Update or insert a Meteor Collection
doc = Collection.findOne({owner: Meteor.userId()});
doc ? Collection.update({_id: doc._id}, {$set: {field: value}}) : Collection.insert({owner: Meteor.userId(), field: value});
// Count collections
Collection.find({}).count()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment