您好,我需要以某种方式传递过滤器方法 2 个或更多参数。就像是r.table("N/A").filter(function(arg1,arg2){..code here})
我需要它来做以下事情:
我有一个如下的数据结构:
"client":{
"name":"andrew",
"coords":{"lat":200,"long":300}
}
我想获取所有客户端的列表,对于此列表中的每个客户端,我希望他的属性与其他尊重过滤谓词的客户端合并。我需要将多个参数传递给过滤函数。
clients{
client:{
"name":"andrew",
"coords":{"lat":200,"long":300}
"neighbours":{
"name":"Dean","coords":{"lat":100,"long":200}
"name":"Sean","coords":{"lat":55,"long":120}
}
client:{
"name":"Dean",
"coords":{"lat":100,"long":200}
"neighbours":{
"name":"Sean","coords":{"lat":55,"long":120}
}
client:{
"name":"Sean",
"coords":{"lat":100,"long":200}
"neighbours":{}
}
}
我失败的尝试:
r.db("cldb").table("clt").pluck(
{"name","coord"}).merge(function(currentClient){
return {
r.db("cldb").table("clt").filter(
function(currentClient,neighbourClient){
currentClient("lat").gt(neighbourClient("lat"))
.and(currentClient("long").gt(neighbourClient("long")))}
)}
})