I'm attempting to use Eve to provide an RESTful API for a simple list of items.
I'd like to use 1) one HTTP request to create a list (possibly with initial items), 2) one HTTP request to add an item(s) (a common operation), 3) one HTTP request to get the list (including all child items). In other words:
1) POST /lists
with body
{
"title": "My List",
"items": [{
"name": "Alice"
},
{
"name": "Bob"
}]
}
2) POST /lists/555555555555555555555555/items
with body
{
"name": "Carol"
}
3) GET /lists/555555555555555555555555
{
"_id": "555555555555555555555555",
"title": "My List",
"items": [{
"_id": "aaaaaaaaaaaaaaaaaaaaaaaa",
"name": "Alice"
},
{
"_id": "bbbbbbbbbbbbbbbbbbbbbbbb",
"name": "Bob"
},
{
"_id": "cccccccccccccccccccccccc",
"name": "Carol"
}]
}
I haven't figured out how to do this with Eve. I can do (1) using an embedded list of dicts, but then I can't do (2)—I'd have to POST an item and then PATCH the list (?). I can do (2) using sub-resources, but then I can't do (1) ("value '{'name': 'Alice'}' cannot be converted to a ObjectId"
). Or am I missing something?
If all three can't be done, could at least both (2) and (3)?