您的位置:首页技术文章
文章详情页

mongodb - python mongo findAndModify如何限制数量

【字号: 日期:2022-10-13 18:43:10浏览:69作者:猪猪

问题描述

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.

标签: Python 编程
相关文章: