Use the former approach if your array will be relatively small (say, under ~2000 items). Use the latter if the number of relationships is much bigger than that.
As far as compound indexes, we don't have support for that yet, but it will happen.
I can then say: table("A-to-B").eq_join("a_id", table("A")).zip().eq_join("b_id", table("B")).zip()
And you'll get a document for each corresponding pair. If the ids are in an array then it's going to be a bit painful to write that query. (Although it can be done I believe).
A future feature will probably be to make eq_join work with arrays of foreign keys.
Nice!!!
This approach could work well when:
- you don't access child documents directly
- you don't update child documents too often
- child documents are usually unique entities
As you can see from the rules above, this would not be a good solution for the Store -> Categories -> Products (contradicts 1. and 3.) But it could work with models like Content -> Votes, Blog -> Comments, etc.
Also, in your API documentation [1], I see there's an `append` function to add a value to an array. Is there an equivalent function to remove a value from an array?
What would be the best way to set up a one-to-many relationship in RethinkDB? For example, a User has a Store, a Store has Categories, and a Category has Products.
Along the same lines, is there some functionality similar to MongoDB's compound indexes?