当我eq加入子文档数组时,我没有得到任何结果(也没有错误)。
考虑用户的以下结构
用户表:
{
"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"
}
]
}
爱好表:
{
id : "reading",
type : "outdoor"
}
预期结果:
{
"email" : "email@emaildomain.com",
"hobbies" : [{
"id" : "reading",
"params" : {},
"type" : "outdoor",
"frequency" : "daily"
}]
我尝试使用以下查询但没有成功。
r.db('test').table("users")
.getAll('email@emaildomain.com', {'index' : 'email' })
.pluck('hobbies')
.getField('hobbies')
.eqJoin('id' , r.db('test').table('hobbies'))
我在这里做错了什么?
答案 0 :(得分:0)
选中此How to join tables with a array of IDs
根据以上链接,查询为
r.db('test').table("users")
.getAll('email@emaildomain.com', {'index' : 'email' })
.concatMap(function (x) {
return x("hobbies");
})
.eqJoin('id', r.db('test').table('hobbies'))