Firebase Realtime Database can only filter the direct child nodes on which you run the query. The value which you order/filter on must be at a fixed path under each direct child node.
In your data structure you seem to have two unknown keys: UID
and unique_recordid
. This means you cannot query for shopId
from Products
.
You can query the records for a single user:
db.child("Products").child("UID of a specific").child("Records")
.orderByChild("shopId").equalTo("value of shopId")
But you can't do the same query on all of Products
as the path of the shopId
property is not the same for all child nodes of Products
.
Also see Firebase Query Double Nested
If you want to query for records with a specific shopId
, you'll need in your database a flat list of exactly those nodes.
Records: {
"recordid1" : {
uid: "...",
productId: "...".
...
},
"recordid1" : {
uid: "...",
productId: "...".
...
}
}
On this data you can then query for productId
and look up the other data, including the UID that is now duplicated for each record.