Chaitu. Petluri
Chaitu. Petluri

Reputation: 45

Firebase orderByChild not getting results

I am trying to query my database to get all the dates which has child number > 7

this.extra = function() {
    refer = ref.child(slot);
    refer.orderByChild('number')
         .startAt('7')
         .once('value')
         .then(function (snapshot) {
             console.log(snapshot.key());
         });
}

But am getting null results, any idea why?

A look at firebase database

Upvotes: 0

Views: 368

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599001

You're passing in '7' (with quotes) but have the value stored as 7 (without quotes). This means that you're comparing strings and numbers, which will not work.

Instead use this:

ref.child(slot)
   .orderByChild('number')
   .startAt(7)
   ...

Upvotes: 1

Related Questions