in second part of logic which comes later I would like to take new found value of txt[0].count , say = 2
and then replace it back into count field so now it should be 3?
.then(txt => FutureTasks.update({userid: txt[0]._id}, {$set: {count: txt[0].count + how to get previous value set above?}}))
However, this is not exposed on Meteor’s minimongo, so you will need to wrap the underlying rawCollection object, either with Meteor.wrapAsync:
const raw = myCollection.rawCollection();
const findAndModify = Meteor.wrapAsync(raw.findAndModify, raw);
// then use as
findAndModify(query, sort, doc, options);
or as a Promise, which you will get automatically with Meteor 1.4:
myCollection.rawCollection().findAndModify(query, sort, doc, options); // returns a Promise
EDIT: I note from the above link that findAndModify is deprecated and that you shoud use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.
I may not always want to $inc because it is taking a previous value and modifying to a new numerical value, but rather I am trying to find existing value in Mongodb that corresponds to userid and add it to a new value which is unknown
but not db.future_tasks.findAndUpdate, db.future_tasks.findAndDelete and db.future_tasksfindAndReplace? findAndModify is deprecated but yet it is the only one available???