I am trying to retrieve data from firebase in such a way that I can count the no of devices (child node inside rooms key) which are turned on (value of child "status" == true).But I am not able to think a optimized solution for this. I tried retrieving data as map and then iterating each key value to find the count but it will be very complex and data consuming.
Is there any way like Querying or something which can do this task.
My database :
{
"users" : {
"ct7H9vr5XcSJo1fALsM0QCqGkDl2" : {
"child account" : {
"VLFgvcXYm6Mj3KEDpqjbrQjyB9V2" : true,
"dWzF1xRDymefLEDTNP32exFxoWT2" : true
},
"rooms" : {
"fvyvybuwe12445" : {
"Devices" : {
"-MnVQp2bZNjGmgmjKnfI" : {
"device name" : "A",
"device type" : "Light",
"pos" : 1,
"status" : true,
"switch no" : 3
}
},
"room name" : "my living room",
"room type" : 2
},
"ghjnnh543456" : {
"Devices" : {
"-MnR0TSC8J__sVtqwmr9" : {
"device name" : "A",
"device type" : "Fan",
"pos" : 1,
"speed" : 2,
"status" : true,
"switch no" : 4
}
},
"room name" : "my dining room",
"room type" : 0
}
}
}
}
}