I'm trying to run a firebase realtime database query to filter data based on value nested at 4th level from root. Below is the data structure and my query is:
let ordersSnapshot = await admin.database().ref(`orders`).orderByChild(`info/infoStatus`)
.equalTo("In Process")
.once('value');
But this query is returning no data. I have enabled indexing and there is no warning for it. I have also changed my query to .orderByChild('infoStatus')
as well but no result.
If I set my ref one level below i.e. admin.database().ref('orders/userId1').orderByChild('info/infoStatus').equalTo("In Process")
then it gets the result successfully. But in my scenario I don't have the user id which I can use in orderByChild
.
Is this the limitation of realtime database query i.e. I need to update my data structure or is there any error in my query ?
Orders Node:
{
"userId1": {
"orderId1": {
"info": {
"infoStatus": "In Process"
}
},
"orderId2": {
"info": {
"infoStatus": "Complete"
}
}
},
"userId2": {
"orderId1": {
"info": {
"infoStatus": "In Process"
}
}
},
"userId3": {
"orderId1": {
"info": {
"infoStatus": "In Process"
}
}
}
}