【发布时间】:2019-09-13 13:50:18
【问题描述】:
我正在尝试运行 firebase 实时数据库查询,以根据嵌套在根目录第 4 级的值过滤数据。以下是数据结构,我的查询是:
let ordersSnapshot = await admin.database().ref(`orders`).orderByChild(`info/infoStatus`)
.equalTo("In Process")
.once('value');
但是这个查询没有返回任何数据。我启用了索引,没有任何警告。我也将查询更改为.orderByChild('infoStatus'),但没有结果。
如果我将我的 ref 设置为低于一级,即admin.database().ref('orders/userId1').orderByChild('info/infoStatus').equalTo("In Process"),那么它会成功获得结果。但在我的场景中,我没有可以在 orderByChild 中使用的用户 ID。
这是实时数据库查询的限制,即我需要更新我的数据结构还是我的查询有任何错误?
订单节点:
{
"userId1": {
"orderId1": {
"info": {
"infoStatus": "In Process"
}
},
"orderId2": {
"info": {
"infoStatus": "Complete"
}
}
},
"userId2": {
"orderId1": {
"info": {
"infoStatus": "In Process"
}
}
},
"userId3": {
"orderId1": {
"info": {
"infoStatus": "In Process"
}
}
}
}
【问题讨论】:
标签: javascript firebase firebase-realtime-database firebase-admin