所以我有一个 mongo 对象:
@connection.register
class UserInformation(Document):
structure = {
'extra_infos':[{
'nickname':basestring,
'name_on_account':basestring,
}],
'age': int,
'mean_distance':float,
}
我将文档更新为此
@connection.register
class UserInformation(Document):
structure = {
'extra_infos':[{
'nickname':basestring,
'name_on_account':basestring,
'email':basestring,
}],
'age': int,
'mean_distance':float,
}
然后我继续进行以下迁移:
class UserInformationMigration(DocumentMigration):
def allmigration01_email(self):
self.target = {'extra_infos':{'$exists':True},'extra_infos.email':{'$exists':False}}
self.update = {'$set':{'extra_infos.email':[]}}
然后我执行了以下命令
migration = UserInformationMigration(UserInformation)
migration.migrate_all(collection=connection['user_info'])
但我不断收到以下错误:
UpdateQueryError: 'extra_infos.email' not found in UserInformation's structure
我究竟做错了什么?是因为 extra_infos 是一个数组吗?我怀疑我的迁移定义不正确,但我不确定如何为数组 extra_infos 以不同方式定义它