I have the following structure:
structure = {
'firstname': basestring,
'lastname': basestring,
'genres': [basestring],
'address': [
{'number': basestring, 'street': basestring, 'town': basestring}
],
'phone': [
{'type': basestring, 'number': basestring}
],
}
And I have a small helper method to iterate over cursors to return a python dict like so:
def to_django_context(cursor):
records = []
for r in cursor:
records.append(r.to_json_type())
return records
this works fine until I want to add another nested field to the structure like this:
structure = {
'firstname': basestring,
'lastname': basestring,
'genres': [basestring],
'address': [
{'number': basestring, 'street': basestring, 'town': basestring}
],
'phone': [
{'type': basestring, 'number': basestring}
],
'title': [{'TEST_FIELD': basestring}],
}
at which point my cursor iterator fails with a KeyError. If I delete all the documents in the collection it works normally. So does this mean that everytime I change my document structure object I have to essentially drop the collection?
Cheers, F