我是 MOngoDB 的新手(来自 CouchDB),在使用 MonDB python 驱动程序向 MongDB 中的文档添加新属性时遇到问题。
例如,我有以下文档:
{
'_id':123456,
'text':"this is nice"
}
而我想插入一个新的属性,例如:
{
'_id':123456,
'text':"this is nice",
'created_time':datetime.datetime.now()
}
如何将 created_time 属性添加到我的文档中?
谢谢!
最佳答案
db.collection.update({'_id' : ObjectId(...)},
{'$set' : {'create_time' : datetime(..) }})
https://stackoverflow.com/questions/5056190/