(对不起,问题的标题很尴尬)你好,我有两张表,数据如下:
//friend_group table
{
.....
{
"id":"user-me"//owner id
"FriendGroups":[
{"id":"friendGroup_1","Members":["friend_1","friend_2"]},
{"id":"friendGroup_2","Members":["friend_1","friend_3","friend_4"]},
]
}
.....
}
//friend table
{
.....
{"id":"friend_1","Skills":["java","c++"]}
{"id":"friend_2","Skills":["python","ruby"]}
{"id":"friend_3","Skills":["golang","c++"]}
{"id":"friend_4","Skills":["javascript","ruby"]}
....
}
我想查询“user-me”的朋友,他们被分配到组“friendGroup-2”并拥有技能“c++”,给定的数据结果应该是:
["friend_1","friend_3"]
我试过这样:
r.db("test").table("friend").filter(function(u){
return r.table("friendGroup").get("user-me")("FriendGroups").filter(function(fg){
return fg("id").eq("friendGroup_2").and(fg("Members").contains(u("id")))
})}).pluck("id")
我的脚本有什么问题?
更新我的脚本是:
r.db("test").table("friend").filter(function(u){
return r.table("friendGroup").get("user-me")("FriendGroups").filter(function(fg){
return fg("id").eq("friendGroup_2").and(fg("Members").contains(u("id")))
})}).filter(function(u){return u("Skills").contains("skill-2")}).pluck("id").pluck("id")