I'm trying to model a fairly simple relationship in CouchDB and I'm having trouble determining the best way to accomplish this. I'd like users to be able to create lists of video game objects. I have the video game documents stored in the DB already with "type":"game"
. I'd like to be able to query a list object's ID (via a view) and get back the list's metadata (title, creation date, etc.) and portions of the game document (such as title and release date). Furthermore, I'd like to be able to add/removes games to/from lists without downloading the entire list document and posting it back (so this means I can't simply store the game's information in the list document) as I'd eventually like to support multiple users contributing to the same list, and I don't want to introduce conflicts.
After reading the CouchDB wiki on EntityRelationships, I've determined that setting up relationship documents might be the best solution.
Game:
{
"_id": "2600emu",
"type": "game"
}
List:
{
"_id": 123,
"title": "Emulators",
"user_id": "dstaley",
"type": "list"
}
Game-List Relationship:
{
"_id": "98765456789876543",
"type": "relationship",
"list_id": 123,
"game_id": "2600emu"
}
But, from what I understand, this wouldn't allow me to get the list's metadata and the game's metadata in one request. Any advice?