0

I'm using firebase database on my test project, what I wanted to do is something similar to how this query on mysql works.

SELECT COUNT(*) FROM tblflashnews WHERE substr(dateCreated,1,10) = 2018-10-01 

Is there a way to get the total count based on the child value.

[{
book:{
     detail:{
         dateCreated: 2018-10-01 10:10:10,
         item: bible
         }
    }
},
{
book:{
     detail:{
         dateCreated: 2018-10-01 10:10:10,
         item: bible
         }
    }
},
{
book:{
     detail:{
         dateCreated: 2018-13-01 10:10:10,
         item: bible
         }
    }
},
{
book:{
     detail:{
         dateCreated: 2018-12-01 10:10:10,
         item: bible
         }
    }
}]

I tried using .numChilden(), but it only get the total child count of a parent. But when I use it inside forEach, it returns an error numChildren is not a function so from this example only count 2 is being return since it has the same value.

{
  book: 2
}
KENdi
  • 7,576
  • 2
  • 16
  • 31
Lion Smith
  • 647
  • 3
  • 16
  • 48
  • see https://stackoverflow.com/questions/15148803/in-firebase-is-there-a-way-to-get-the-number-of-children-of-a-node-without-load – Aaron Saunders Oct 03 '18 at 03:05
  • what i wanted to achieve is to get all the data from the child node dateCreated of each users... – Lion Smith Oct 03 '18 at 07:14
  • based on your link the user id also included.. what i wanted was to get all the dateCreated of each user without using their id..then count the result – Lion Smith Oct 03 '18 at 07:18
  • this link isnt always the exact answer for you to cut and paste, but to provide you the information to derive your solution – Aaron Saunders Oct 03 '18 at 19:44

0 Answers0