使用 pymongo 在 mongodb 中执行更新操作后,如何检索修改后的文档? [英] How can i retrieve modified documents after an update operation in mongodb with pymongo?
本文介绍了使用 pymongo 在 mongodb 中执行更新操作后,如何检索修改后的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有 upsert 的更新操作.我想检索更新后修改过的所有文档.
I'm using an update operation with upsert. I want to retrieve all documents that have been modified after an update.
for key in categories_links:
collection.update({"name" : key}, {"name": key ,"url" : categories_links[key]}, True)
推荐答案
如果您需要查找更新的时间和地点,您应该在文档中使用时间戳字段.有一个 BSON 类型.
You should use a timestamp field in your documents if you ever need to find which ones where updated and when. There is a BSON type for that.
这篇关于使用 pymongo 在 mongodb 中执行更新操作后,如何检索修改后的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文