I'm struggling to locate and update a field within a document using Monk. The issue lies in my attempt to use a variable in the property section (property: value). The type, as well as the value.
let result = await collection.findOneAndUpdate({type: value}, { $set: { blacklisted: false} })
When I assign the type to something like apple with let type = "apple"
, it doesn't recognize the type variable in findOneAndUpdate.
However, if I simply input apple directly like this
let result = await collection.findOneAndUpdate({"apple": value}, { $set: { blacklisted: false} })
It works perfectly fine.
I also attempted to turn this into an object, such as: let obj = {type, value}
and then used that in the find and update
let result = await collection.findOneAndUpdate(obj, { $set: { blacklisted: false} })
Still no success. Any suggestions? Thanks.