Reputation: 5262
Let's say I have two tables: Car
and Wheel
. A Car
has many Wheel
s. Car
has an indexed field: Owner
.
Now, if I wanted a change feed for all Wheel
s which are owned by "Foo"
, then it seems I have to duplicate the Owner
field on the Wheel
table and then whenever the parent Car
changes, I'd need to perform the same update on child Wheel
s – this feels like a poor solution though.
I tried adding a Owner
index function on Wheel
referencing the parent:
r.table('Wheel').indexCreate("Owner", function(wheel) {
return r.table('Car').get(wheel("CarID"))("Owner")
});
Though this returns "Index functions must be deterministic"
.
What is the best way to do this?
Upvotes: 0
Views: 42
Reputation: 5289
You're right; you have to put Owner
onto Wheel
, or else put your wheels into an array in your Car
table (which is probably more common). Changefeeds can't include predicates that span multiple tables.
Upvotes: 1