Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get data from firebase with filter

I am new with firebase, so don't be very strict... I have next database:

{"list":[
          {
             "id":0,
             "name":"name",
             "text":"text"
          },
          {
             "id":1,
             "name":"name",
             "text":"text"
          },
          {
             "id":2,
             "name":"name",
             "text":"text"
          },
          {
             "id":3,
             "name":"name",
             "text":"text"
          }
    ]
}

enter image description here

Here is my code for request:

FirebaseDatabase database = FirebaseDatabase.getInstance();
Query mQuery = database.getReference("list")
                .child("id").startAt("2");
mQuery.addListenerForSingleValueEvent(eventListener);

but this request return null...

Will be glad any idea?

UPDATE

I need to get all items where id is bigger than asked one.

like image 821
Stan Malcolm Avatar asked Aug 08 '26 09:08

Stan Malcolm


1 Answers

You need to add an order-by method

Query mQuery = database.getReference("list")
            .orderByChild("id").startAt(2);

It should work

like image 198
Wilik Avatar answered Aug 10 '26 21:08

Wilik