文章詳情頁
mongodb - python mongo findAndModify如何限制數量
瀏覽:204日期: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.
相關文章:
1. docker鏡像push報錯2. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. docker - 如何修改運行中容器的配置5. javascript - 請指條明路,angular的$event,在select中卻是undefined?6. java - 如何點擊按鈕,重新運行(我是初學者)?7. html5和Flash對抗是什么情況?8. javascript - 在 model里定義的 引用表模型時,model為undefined。9. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????10. phpstudy8.1沒集成mysql-front
排行榜

網公網安備