How to get the object id in PyMongo after an insert?

后端 未结 6 1133
旧巷少年郎
旧巷少年郎 2020-12-08 13:10

I\'m doing a simple insert into Mongo...

db.notes.insert({ title: \"title\", details: \"note details\"})

After the note document is inserte

6条回答
  •  温柔的废话
    2020-12-08 13:58

    updated; removed previous because it wasn't correct

    It looks like you can also do it with db.notes.save(...), which returns the _id after it performs the insert.

    See for more info: http://api.mongodb.org/python/current/api/pymongo/collection.html

提交回复
热议问题