How to get firebase items by query or any thing else


#1

hello guys

How can I get the data of last 10 elements of firebase
or how can I get the items of last 2 weeks from today

I’m using this code to get all data,

this.itemList = this.afd.list('/items/')

but i don’t know how it work with dates or limit number of items


#2
const queryObservable = db.list('/items', {
  query: {
    orderByChild: 'size',
    equalTo: 'large' 
  }
});

to oder by date use orderByKey

here is the documentation

https://github.com/angular/angularfire2/blob/master/docs/4-querying-lists.md


#3

Thank u very much

But what about if I want to get items of last 2 weeks from today ?

For this problem, I couldn’t find the solution until now :frowning: :cry:


#4

Is there any solution for this point ?


#5

have you taken a look at this?


#6

What if those items were created with a unique auto generated ID by firebase? So it would be items/UUID/item.property. How would you query those items?