im using firebase database on my test project what i wanted to do is something similar to how this query on mysql works..
select COUNT(*) as title, date from users group by date
this is how my firebase db looks like..
users
|--askdoawih123hi1h2i
|--name:"john"
|--last:"kill",
|--date:"2018-01-06 18:00"
|--askdo7a87sd56as1h2i
|--name:"Doe",
|--last:"kill",
|--date:"2018-01-06 18:00"
|--askdoawa78sd7a81h2i
|--name:"Mike",
|--last:"kill",
|--date:"2018-01-07 18:00"
|--askd8a9sd8as9a89si1h2i
|--name:"Ron",
|--last:"kill",
|--date:"2018-01-08 06:00"
|--askdoaa9sda98a3hi1h2i
|--name:"mich",
|--last:"kill",
|--date:"2018-01-09 06:00"
and the result that i wanted to achieve was something like this.
[{title:"2", star:"2018-01-06", title:"1", start:"2018-01-07", title:"1", start:"2018-01-08",title:"1", start:"2018-01-09",}]
and this is my script..
ref.once('value', function (snapshot) {
var promises = [];
var childData = snapshot.numChildren();
snapshot.forEach(function (childSnapshot) {
startTime = childSnapshot.val().startDateTime;
promises.push({
title: childData,
start: startTime
});
});
res.json(promises);
});
the result of this query is like this..
[{"title": 5,"start": "2018-01-06 18:00"},{"title": 5,"start": "2018-01-06 18:00"},{"title": 5,"start": "2018-01-07 18:00"},{"title": 5,"start": "2018-01-08 06:00"},{"title": 5, "start": "2018-01-09 06:00"}]
is there a way to achieve how the query of mysql works in firebase?