I have a Document where a user has 2 addresses such as below. How would I create a schema for this in python-eve?
Also, How would I create an API request to allow a user to update only the zipcode. Do they have to repost the entire document?
{
_id: "joe",
name: "Joe Bookreader",
addresses: [
{
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
},
{
street: "1 Some Other Street",
city: "Boston",
state: "MA",
zip: "12345"
}
]
}
As far as the schema goes, this should do the trick (docs):
'addresses': {
'type': 'list',
'schema' {
'type': 'dict',
'schema': {
'street': {'type': 'string'},
'city': {'type': 'string'},
'state': {'type': 'string'},
'zip': {'type': 'string'}
}
}
}
Dot notation is supported for PATCH (update) requests, but not on lists of documents. They are trickier, and hard to do in a RESTful way. There's an open ticket for that right now, but not direct solution yet, I am afraid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With