Reputation: 123
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");
Upvotes: 0
Views: 251
Reputation: 51
.table("tblName1").innerJoin(
r.table("tblName2"), function(tl, path){
return tblName1("value").eq(path("value"));
}
).map({nodeName:r.row("right")("value")
})
Upvotes: 1
Reputation: 51
r.table("tblName1").get(id).innerJoin(
r.table("tblName2"),
function (tbl1, tbl2) {
return tbl1("userId").eq(tbl2("userid"));
})
Upvotes: 3
Reputation: 51
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 :)
Upvotes: 1