Firebase Database - Getting Multiple Records

My data is denormalized and uses a reverse index, as suggested by the firebase command. Something like:

{ "users": { "alovelace": { "name": "Ada Lovelace", // Index Ada groups in her profile "groups": { // the value here doesn't matter, just that the key exists "techpioneers": true, "womentechmakers": true } }, ... }, "groups": { "techpioneers": { "name": "Historical Tech Pioneers", "members": { "alovelace": true, "ghopper": true, "eclarke": true } }, ... } } 

Now I want to download all Ada groups. I can easily get a list of identifiers of the groups to which it belongs, starting from part of its user object.

Is there a way so that I can request all specific Ada groups by ID at the same time? Or do I need to create a ValueEventListener identifier for each group and request each group separately?

On the security side - let's say that each group is read only by its members, so I can’t query all the groups and sort them after the fact.

+5
source share
1 answer

I think you could do something like:

 var ref = new Firebase("<..>/groups"); ref.orderByChild("members/alovelace").equalTo(true) .once('value').then(function(dataSnapshot) { // handle read data }) 

(Unverified, but according to this Deep queries are now supported)

+1
source

All Articles