Firestore query by date range

前端 未结 9 915
悲&欢浪女
悲&欢浪女 2020-12-02 12:11

I need the help to query long collection with date range. See the below example document. I wanna query startTime field using date range.

9条回答
  •  一向
    一向 (楼主)
    2020-12-02 12:40

    The solution is to use Date.now (), stop using timestamp service from firebase, you need to work with the numerical value of the time in milliseconds like for example: 1514271367000, instead if firestore uses 26/12/2017 1:56:07 GMT- 0500 (-05) will not work. An example of a query is:

    this.fsService.afs.collection('chats/4bY1ZpOr1TPq8bFQ3bjS/finance/123+finance/12345'
              , ref => ref.orderBy('hour').startAt(1514184967000).endAt(1514271367000))
              .valueChanges().subscribe(data =>{
                this.mensajes = data;
              })
    

提交回复
热议问题