Configure pymongo to use string _id instead of ObjectId

后端 未结 2 1772
误落风尘
误落风尘 2021-01-03 02:48

I\'m using pymongo to seed a database with old information from a different system, and I have a lot of queries like this:

studentId = studentsR         


        
2条回答
  •  一整个雨季
    2021-01-03 03:33

    in .py files:

    from bson.objectid import ObjectId
    ......
    kvdict['_id'] = str(ObjectId())
    ......
    mongoCollection.insert(kvdict)
    

    it's ok!

提交回复
热议问题