Firebase Filter by Date

前端 未结 1 1144
孤独总比滥情好
孤独总比滥情好 2021-01-01 04:00

My data:

\"Data\"

I am looking for a way to filter the dates using a custom date range. I\'ve s

相关标签:
1条回答
  • 2021-01-01 04:30

    You're trying to filter on date values, but you're ordering on type That's not how Firebase Database queries work: you always first order on a property/value, and then filter on that same property/value.

    So to order/filter on regdate:

    firebase.database().ref().child("Users").orderByChild('regdate')
      .startAt("2019-01-05").endAt("2019-01-10");
    

    Note that I also changed endat to endAt (with an uppercase A). The endat you had, will give a syntax error.


    You're now ending at 2019-01-10. Since your actual values include a time, they will all fall right after this value. If you also want to include the users who registered on 2019-01-10 itself, use:

    firebase.database().ref().child("Users").orderByChild('regdate')
      .startAt("2019-01-05").endAt("2019-01-10 23:59:59");
    
    0 讨论(0)
提交回复
热议问题