I need to read a document from a collection, read its value, then if the value is <40 I need to increment the value.
Here is my current solution
let promise = db.collection('transactions').findOne(
{ _id: 'myid' }
).then(doc => {
if (doc.count < 40) {
///update & increment doc.count
}
else {
//do not increment
}
});
Does findOneAndModify allow for reading the document before modifying?