I have two simple tables:
Users Table:
{
"activated": true ,
"created": Wed Jun 22 2016 15:22:32 GMT+00:00 ,
"email": email@email.com, »
"id": "5071f620-576a-49c0-ae84-e9f32db2a034" ,
"roles": [
"Admin"
] ,
"sso": "123456789"
}
Roles Table:
{
"id": "f62b1d29-84d1-4bad-a359-dacb8678f607" ,
"permissions": [
"add" ,
"delete"
] ,
"role": "Admin"
}
I am running a query to get the permissions of a given user. I am doing the following:
r.db('content').table("users").merge(function(user){
return r.object(
'permissions', user('roles').eqJoin(function(id){
return id
}, r.db('content').table('roles')).zip()('permissions')
.reduce(function(left, right){
return left.merge(right)
})
)
});
But I am getting an error:
Server error:
e: Cannot reduce over an empty stream
What am I doing wrong and why? My desired output will give me a user with their permissions.