文章詳情頁
mongodb - python mongo findAndModify如何限制數量
瀏覽:112日期:2022-10-13 18:43:10
問題描述
findAndMondify中有個query參數,有個update標簽,可是如何限制搜索數量也就是把下面兩個語句合一db.xxx.find({name:'xxx',age:3}).limit(10)db.xxx.update({name:'xxx'},{$set:{age:5}},false,true)
問題解答
回答1:findAndModify方法用于將查找和修改放在一個原子操作中,它一次只能操作一條數據。可以參考文檔了解具體用法:
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.
相關文章:
排行榜
