1
我需要通過嵌套對象過濾數據的解決方案。 所以,這是我的JSON數據:嵌套對象上的RethinkDB過濾器
{
"create_datetime": 1431000977 ,
"creator": {
"company": {
"id": 0 ,
"name": "Some name"
} ,
"manager": {
"id": 0 ,
"name": ""
}
} ,
"finished_datetime": 1431615600 ,
"id": "00949296-cbea-4d4a-a780-7c8d918a7fd6" ,
"participants": [ ],
"status": "created" ,
"tender_categories": [
1285
] ,
"views": [ ]
},
{
"create_datetime": 1431416740 ,
"creator": {
"company": {
"id": 70922233 ,
"name": "Some company name"
} ,
"manager": {
"id": 1003546168 ,
"name": "Some manager name"
}
} ,
"finished_datetime": 1432857600 ,
"id": "28e0936b-84e0-4ffc-9ad1-78a1d34e9033" ,
"participants": {
"788190": {
"creator": {
"company": {
"id": 788190 ,
"name": "Company name"
} ,
"manager": {
"id": 1003546168 ,
"name": "Manager Name"
}
} ,
"dt_applied": 1431416778 ,
"viewed": false
}
} ,
"status": "created" ,
"tender_categories": [1303] ,
"views": [788190]
}
我需要從這個JSON,我們有參與者選擇一個記錄,那看過。我寫了很多代碼,但其中一個工作。
r.db('test').table('tenders').filter(function(tender) {
return tender('participants').coerceTo('array').map(function(participant) {
return participant('viewed').eq(false)
});
});
和
r.db('pm').table('b2b_tenders').map(function(tender) {
return tender('participants').filter(function(key) {
return tender(key)('viewed').eq(false)
});
});
等一個。幫助一下。