There is a query parameter and an update tag in findAndMondify.
But how to limit the number of searches?
That is, combine the following two statements into one
db.xxx.find({name:"xxx" ,age:3}).limit(10)
db.xxx.update({name:"xxx"},{$set:{age:5}},false,true)
The
findAndModify
method is used to put search and modification in an atomic operation, which can only operate on one piece of data at a time.You can refer to the documentation for specific usage: