Migrations in mongoengine: InvalidId

前端 未结 2 604
南旧
南旧 2021-02-06 09:43

I am working with mongoengine and trying to do a simple migration. I have a field which I would like to migrate from being a StringField to a ReferenceField to another Object.

2条回答
  •  一整个雨季
    2021-02-06 10:19

    The 2 options I would suggest for your migration script:

    • using DynamicField on the field you must migrate should allow you to read ObjectIds and store back DBRefs
    • doing the migration in pymongo directly (pymongo's collection is accessible through Person._get_collection()) and looping over the items, updating & saving

提交回复
热议问题