I have a rethinkdb table which have 5 rows, one of the row is following:
{
"appkey": {
"YcJ1HR6vjebXNHwOzeC2l2EAvUNw8qyp": {
"createdBy": {
"fullName": "DD" ,
"id": "7943d176-4805-461d-841e-3de766a3825d" ,
"primaryName": dd@gmail.com, ยป
} ,
"creationTime": "2016-01-20T05:57:40.773+00:00" ,
"expiryTime": "2017-01-20T05:57:40.539+00:00"
}
} ,
"creationTime": "2016-01-20T05:57:40.773+00:00" ,
"customerId": "U2KRpPbK" ,
"domain": "co.in" ,
"id": "40e536cc-08f1-4a54-8104-13d900abd643" ,
"kind": "admin#option1#option2" ,
"roles": {
"admin#option1#option2": {
"create": true ,
"delete": true ,
"modify": true ,
"read": true
}
}
}
}
In this case how can I fetch above row based on the appKey's field "YcJ1HR6vjebXNHwOzeC2l2EAvUNw8qyp", which is token that I am getting form client end.
To do the same I tried with following query:
r.db('admin').table('services')
.filter(function (record) {
return record('appkey').coerceTo('array')
.map(function (record) {
return record(1).hasFields(token)
});
.distinct()
})
.run()
But above query returning only 1 row in every case whether the token is for 4 row or 2 row.
What I am doing wrong!