given a similar schema for people as:
[{
"id": 1,
"name": "Darth",
"family": [2,3]
},
{
"id": 2,
"name": "Luke"
},
{
"id": 3,
"name": "Leia"
}
]
how do I return Darth and outer join to get all his family?
given a similar schema for people as:
[{
"id": 1,
"name": "Darth",
"family": [2,3]
},
{
"id": 2,
"name": "Luke"
},
{
"id": 3,
"name": "Leia"
}
]
how do I return Darth and outer join to get all his family?
Ended up with the below which will be much more performant than a map I believe. And it will use the default index on id
r.db('myDb')
.table('tests')
.get(1)
.merge(function (person) {
return {
myFamily: r.db('myDb').table('tests').getAll(r.args(person('family'))).coerceTo('ARRAY')
}
})
.pluck('name', 'myFamily');
I you want the ids in
family
to be replaced with the documents for the family members, you can do amap
with aget
.Like this:
The result of this query will be something this: