javascript - MongoDB Meteor.js Increment var from a var in another document -
i have this:
i can't seem able modify multiple documents same time.
click: function() { var power = meteor.user().power; var mult = meteor.user().mult; meteor.users.update({ _id: this.userid }, { $inc: { 'money': power * mult, 'lifetimeclick': 1, 'done': 0, 'done2': 0, 'done3': 0, },
how make changes var of document @ same time. please tell me if there other snippets need see or whether or not unclear you.
i want when click button, increments current user's variables , variable of set user have made.
i have tried many things have no idea format use or how go doing this.
i want function take variable 1 document , add variable in document. thing know how add variables in 1 document.
it sounds expect multiple documents in collection meet query criteria, , want update each of documents? if that's case need set the multi parameter.
db.update( _id: theid, { $inc: { value: 1}}, { multi: true});
Comments
Post a Comment