So I have a mongo object:
@connection.register
class UserInformation(Document):
structure = {
'extra_infos':[{
'nickname':basestring,
'name_on_account':basestring,
}],
'age': int,
'mean_distance':float,
}
And I updated the doc to this
@connection.register
class UserInformation(Document):
structure = {
'extra_infos':[{
'nickname':basestring,
'name_on_account':basestring,
'email':basestring,
}],
'age': int,
'mean_distance':float,
}
Then I went ahead with the following migration:
class UserInformationMigration(DocumentMigration):
def allmigration01_email(self):
self.target = {'extra_infos':{'$exists':True},'extra_infos.email':{'$exists':False}}
self.update = {'$set':{'extra_infos.email':[]}}
Then I executed the following commands
migration = UserInformationMigration(UserInformation)
migration.migrate_all(collection=connection['user_info'])
But I keep on getting the following error:
UpdateQueryError: 'extra_infos.email' not found in UserInformation's structure
What am I doing wrong? is it because extra_infos is an array? I suspect that my migration is defined incorrectly, but I am not sure how to define it differently for an array extra_infos
Yes, you are correct. You will need to use this instead:
It will reference the first element in 'extra_infos'.