文章詳情頁
mongodb - python mongo findAndModify如何限制數(shù)量
瀏覽:123日期:2022-10-13 18:43:10
問題描述
findAndMondify中有個(gè)query參數(shù),有個(gè)update標(biāo)簽,可是如何限制搜索數(shù)量也就是把下面兩個(gè)語句合一db.xxx.find({name:'xxx',age:3}).limit(10)db.xxx.update({name:'xxx'},{$set:{age:5}},false,true)
問題解答
回答1:findAndModify方法用于將查找和修改放在一個(gè)原子操作中,它一次只能操作一條數(shù)據(jù)。可以參考文檔了解具體用法:
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.
相關(guān)文章:
1. python 利用subprocess庫調(diào)用mplayer時(shí)發(fā)生錯(cuò)誤2. python文檔怎么查看?3. python - Pycharm的Debug用不了4. javascript - 關(guān)于apply()與call()的問題5. datetime - Python如何獲取當(dāng)前時(shí)間6. javascript - nginx反向代理靜態(tài)資源403錯(cuò)誤?7. html - eclipse 標(biāo)簽錯(cuò)誤8. 請(qǐng)問PHPstudy中的數(shù)據(jù)庫如何創(chuàng)建索引9. 安全性測試 - nodejs中如何防m(xù)ySQL注入10. python - pycharm 自動(dòng)刪除行尾空格
排行榜

熱門標(biāo)簽