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});
Written by Justin Riggio
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mongodb
Authors
dominikgarber
81.15K
sativaware
80.22K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#