文章詳情頁
mongodb - python mongo findAndModify如何限制數量
瀏覽:193日期: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. boot2docker無法啟動2. docker-compose中volumes的問題3. java - SSH框架中寫分頁時service層中不能注入分頁類4. docker容器呢SSH為什么連不通呢?5. dockerfile - 為什么docker容器啟動不了?6. docker安裝后出現Cannot connect to the Docker daemon.7. nignx - docker內nginx 80端口被占用8. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值9. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””10. 關于docker下的nginx壓力測試
排行榜

網公網安備