Last active
October 30, 2016 20:46
-
-
Save RANUX/0f13dd93e34b2f12194f38bd8cb6cb07 to your computer and use it in GitHub Desktop.
Meteor and mongo queries examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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