Meteor client side upsert not allowed -
i building first meteor application , having problem upserting documents collection client side.
i looking update document if in collection , insert 1 if there not. code looks
userdata.upsert( { // selector _id: meteor.users.findone({})._id }, { // modifier $set: { user: meteor.users.findone({}), currentquestions: currentquestion } } ); which allowed
userdata.allow({ insert: function (userid) { // user must logged in, , document must owned user homecoming (userid != null); }, update: function (userid) { // user must logged in, , document must owned user homecoming (userid != null); }, upsert: function (userid) { // user must logged in, , document must owned user homecoming (userid != null); } })
this works insert , update. upsert next error
error: allow: invalid key: upsert ofcourse can utilize if/else insert/update seems bit redundant when .upsert should exact trick. does know how allow .upsert client side?
well that's because don't define separate allow rule upsert, insert, update, , remove (http://docs.meteor.com/#allow). furthermore, "upsert same calling update upsert alternative set true (..)" (http://docs.meteor.com/#upsert).
so short is: create sure rule updating correct.
meteor
No comments:
Post a Comment