5c9bbw
Last Updated: February 25, 2016
·
3.702K
· just_in

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});