![](/img/trans.png)
[英]Firebase Realtime Database - orderByChild().equalTo() does not return expected node
[英]Firebase orderByValue().equalTo() is not a function (Node JS)
我的數據庫具有以下結構:
"groupA" : {
"applications" : {
"applicationID_132" : {
"status" : "accepted"
},
"applicationID_423" : {
"status" : "declined"
},
"applicationID_562" : {
"status" : "accepted"
}
}
}
我正在嘗試通過以下方式檢索具有“已接受”狀態的應用程序快照(以便能夠跳過獲取所有應用程序):
return admin.database().ref('groupA').child('applications').orderByValue('status').equalTo('accepted')
.once('value')
.then(acceptedApplicationsSnapshot => {
似乎不起作用,也嘗試過 orderBy 和 orderByValue。 可能缺少什么或處理這種情況的更好方法是什么? 感謝您的任何幫助!
嘗試使用child.orderByChild().value()
在你的情況下:
return admin.database().ref('groupA').child('applications').orderByChild('status').equalTo('accepted')
.once('value')
.then(acceptedApplicationsSnapshot => {
您也可以使用orderByValue()
,但首先您需要獲取要訂購的 Reference - 函數不接受參數。
.child(..)
返回你的情況的引用是applications
,如果你想使用orderByValue
比你需要這樣做,例如之前得到參考“狀態”:
admin.database().ref('groupA').child('applications').child('status').orderByValue()
然后您將應用其中一種數據過濾方法,例如。 .equalTo('accepted')...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.