I defined a resource with this schema
# 'people' schema definition
'schema'= {
'firstname': {
'type': 'string',
'minlength': 1,
'maxlength': 10,
},
'lastname': {
'type': 'string',
'minlength': 1,
'maxlength': 15,
'required': True,
'unique': True,
},
# 'role' is a list, and can only contain values from 'allowed'.
'role': {
'type': 'list',
'allowed': ["author", "contributor", "copy"],
},
# An embedded list of 'strongly-typed' dictionary.
'locations': {
'type': 'list',
'schema' {
'type': 'dict',
'schema': {
'address': {'type': 'string'},
'city': {'type': 'string'}
},
},
},
'born': {
'type': 'datetime',
},
}
Is it possible to define the location as sub resource by referencing the same data source of people and perform search on it?
e.g. people/< firstname>/locations/< city>
Reply: list of locations
The reason why I need to have locations stored inside the people document is for taking advantage of the document atomicity in mongo.
I might need to update several locations of a person in one transaction. Therefor I want to make sure that all needed locations of a person ( or none) are updated. No intermediate state possible.