There are multiples dates and data for each date. Each date and data store under a unique key.
"Data":{
"K2ngvpioRUYF4bRM07Da5cbAjE53":{
"-M3jNjCuGdMCwt1Czpwz":{
"Date":"2020-3-30",
"Scale":"3"
},
"-M3jQWxm7z0EQYgkVenX":{
"Date":"2020-4-29",
"Scale":"4"
},
"-M5hxn-rCJICUvRcMZJu":{
"Date":"2020-4-24",
"Scale":"2"
}
}
}
I would like to calculate the total number of scales for monthly (The main point is monthly). Instead of using "startAt" and "endAt":
Query query = ref.orderByChild("Date").startAt("2020-3-1").endAt("2020-3-31");
Query query2 = ref.orderByChild("Date").startAt("2020-4-1").endAt("2020-4-30");
Is there any better way to loop for all month and year? I think the above code is hard if I have dates of different years and months.