0

I am not getting any results(no error as well) when I eq join a subdocument array.

Consider the following structure for user

User Table:

{
"email": "email@emaildomain.com",
"id":  "ca433c6a-8cbc-4687-b217-19cabe5fcf63" ,
"image": https://lh4.googleusercontent.com/-44yrW_REeoU/AAEAAAAAAAAI/AAAAAAAAACI/CWvSF3isGRjM/photo.jpg?sz=50, ยป
"name":  "John Doe" ,
"hobbies": [
{
"id":  "reading" ,
"params": { } ,
"freqency" : "daily"
}
]
}

Hobbies Table :

{
id : "reading",
type : "outdoor"
}

Expected Result :

{
"email" : "email@emaildomain.com",
"hobbies" : [{
"id" : "reading",
"params" : {},
"type" : "outdoor",
"frequency" : "daily"
}]

I tried with below query with no success.

  r.db('test').table("users")
    .getAll('email@emaildomain.com', {'index' : 'email' })
    .pluck('hobbies')
    .getField('hobbies')
    .eqJoin('id' , r.db('test').table('hobbies'))

what am i doing wrong here?

anandaravindan
  • 2,401
  • 6
  • 25
  • 35

1 Answers1

0

Check this How to join tables with a array of IDs

Based on the above link, the query is

r.db('test').table("users")
  .getAll('email@emaildomain.com', {'index' : 'email' })
   .concatMap(function (x) {
     return x("hobbies");
   })
    .eqJoin('id', r.db('test').table('hobbies'))
Community
  • 1
  • 1
anandaravindan
  • 2,401
  • 6
  • 25
  • 35