mongodb - python mongo findAndModify how to limit quantity
黄舟
黄舟 2017-05-17 10:03:22
0
1
889

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)

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
曾经蜡笔没有小新

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:

sort document Optional. Determines which document the operation modifies if the query selects multiple documents. findAndModify() modifies the first document in the sort order specified by this argument.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template