The .orderByChild
query only works on the child level. (no grandchilds) In your case this would be the level with the firebase push-keys e.g. -KwqBYHP...
So if you do .orderByChild('sender')
it will not work, since there is no property called sender
on this level.
So you have two options depending on your case. If viePatHR0qRaBPGvsb992LEM55F3
is a unique id you can get rid of the firebase pushkeys by using set
instead of push
to save your data to the database.
If viePatHR0qRaBPGvsb992LEM55F3
is no unique id, then you need to modify your reference.
The modified reference would look like this firebase.database().ref('requests/viePatHR0qRaBPGvsb992LEM55F3').orderByChild('sender')
If this is not what you expect, the only option you have is to rebuild your data structure. Getting rid of the deep nesting by creating for example a property called:
id: "viePatHR0qRaBPGvsb992LEM55F3"
directly on your object (on the same level where the sender
property is).