我在RethinkDB中有一个 person
对象,如下所示:
{
"email": "user@domain.com",
"orders": {,
"id": 1,
"additionalInvoices": [
{
"description": "Bananas",
"stripeChargeId": "ch_333"
},
{
"description": "Apples",
"stripeChargeId": "ch_444"
}
]
}
}
除非没有返回结果 . 我可以嵌套 contains()
功能吗? What's the best way to get the results I want?
Edit: 我也尝试了pluck()并描述了数据结构,按照using nested datastructures in the RethinkDB docs的这个例子 - 我认为这样可行,但它给出了 empty object matching the query as the only result :
rethink.db(DATABASE).table(TABLE).pluck(
{orders: [{additionalInvoices: [{'stripeChargeId': chargeID}]}]}
).run(dbConnection, function(err, results) {
if ( err ) {
cb(err)
return;
}
toOne(results, cb)
})