How to join using embedded links in rethinkdb -


given similar schema people as:

[{   "id": 1,   "name": "darth",   "family": [2,3] },   {     "id": 2,     "name": "luke"   },   {     "id": 3,     "name": "leia"   } ] 

how return darth , outer join family?

i want ids in family replaced documents family members, can map get.

like this:

r.table('people').get(1) // darth   // add `family` property darth   .merge(function (row) {     return {       // map family member ids respective documents       'family': row('family').map(function (id) {         return r.table('people').get(id);       })     }   }) 

the result of query this:

{   "family": [     {       "id": 2 ,       "name":  "luke"     } ,     {       "id": 3 ,       "name":  "leia"     }   ] ,   "id": 1 ,   "name":  "darth" } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -