开发者

MongoEngine specifying an ID

开发者 https://www.devze.com 2023-03-05 21:11 出处:网络
I\'m having trouble getting MongoEngine to accept specific 开发者_如何学编程IDs. It seems absolutely determined to use (and only use) ObjectIds. I\'m more than able to generate my own IDs in this inst

I'm having trouble getting MongoEngine to accept specific 开发者_如何学编程IDs. It seems absolutely determined to use (and only use) ObjectIds. I'm more than able to generate my own IDs in this instance, thanks.

How can I get MongoEngine to play nice?


I managed to solve this by adding the following to the class:

id = mongoengine.StringField(required=True, primary_key=True)

Not sure if this is the "proper" way of doing things, so ill leave this unanswered for a bit.

0

精彩评论

暂无评论...
验证码 换一张
取 消