0

How to Join with multiple conditions and use aggregate function in Rethink-db

r.table("yourtable").get(id).innerJoin(
r.table("secondtable"),function (up, upp) {
      return user_profile("mID")
}).map({  
     uId: r.row("left")("userId"),
     mId: r.row("left")("memberId"),
     pId: r.row("right")("projectId"),      
     nodeId: r.row("right")("nodeId"),
     pri: r.row("right")("priority")
 })
 .min("priority");
Govind Jha
  • 123
  • 2
  • 9

3 Answers3

3
    r.table("tblName1").get(id).innerJoin(
    r.table("tblName2"),
          function (tbl1, tbl2) {
               return tbl1("userId").eq(tbl2("userid"));
     })
1

You can try below one where tblName1 Joins with tblName2. Having userId as mapping key. Note its a innerJoin.

r.table("tblName1").get(id).innerJoin(
   r.table("tblName2"),
   function (tbl1, tbl2) {
   return tbl1("userId").eq(tbl2("userid"));
   }).zip()

Also you can check a reference of all the sql to reql here. Hope it helps :)

iamvik
  • 51
  • 8
1
 .table("tblName1").innerJoin(
   r.table("tblName2"), function(tl, path){
     return tblName1("value").eq(path("value"));
   }
 ).map({nodeName:r.row("right")("value")   
   })