Show the JSON document when referring to it in examples
The docs for RethinkDb are great, but there are a few areas that I think would help. In particular where ReQL is being explained, often there is no sale doc provided where you can follow along. A case in point is secondary indexes (https://rethinkdb.com/docs/secondary-indexes/javascript/) where it shows a lot of samples, but no context to the document being operated on.
For example when I was having issues with a secondary index, I posted in Slack the document (like below)
{
"first_name": "William",
"id": "00039f57-4744-4621-88a9-ccd93c36fd25",
"last_name": "Murphy",
"member_since": "2015-11-29",
"password": "password",
"products": [{
"product": "ABC Blocks",
"product_id": "e9b3605d-8fbd-40d4-ba6b-cf4acf08bced",
"product_type": "toy",
"status": "owned"
}, {
"product": "Reading Time",
"product_id": "48506714-3131-4f49-930c-c199567a2bb7",
"product_type": "book",
"status": "owned"
}, {
"product": "Reading Time",
"product_id": "0a0c4217-6705-4c78-828f-b46624eddcfb",
"product_type": "book",
"status": "wanted"
}],
"username": "WMurphy3792"
}
Which helped get an answer (from Shaggydev) of
r.table("users").indexCreate("status_product", function(user) {
return user("products").map(function(product) {
return [ product("status"), product('product_id') ]
})
}, {multi: true})
I also showed how I wanted to use the index
r.table('users').getAll(['wishlist', 'dbabe660-473f-471f-829e-039c451c6872'], {index:'status_product'})
And probably could have included a note about what it was I was trying to accomplish, like
I want to be able to get all users for a specific product based on the status (owned or wishlist)
So maybe some format like that, where you get the doc, and explanation, the index creation nd the query to use the index would be nice.