本文介绍了Firestore 按日期范围查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助来查询具有日期范围的长集合.请参阅下面的示例文档.我想使用日期范围查询 startTime 字段.
I need the help to query long collection with date range. See the below example document. I wanna query startTime field using date range.
推荐答案由于我将 dueDate 字段存储为timestamp"(而不是 string 或 number)在 Cloud Firestore 上,我这样做是为了获取截止日期为 2017 年的发票文档:
Since I have the dueDate field stored as "timestamp" (and NOT as string or number) on Cloud Firestore, I did this to get the invoice documents with a due date on 2017:
let start = new Date('2017-01-01'); let end = new Date('2018-01-01'); this.afs.collection('invoices', ref => ref .where('dueDate', '>', start) .where('dueDate', '<', end) );注意: dueDate 字段与 Date() 对象一起存储在 firebase 中.例如:this.doc.dueDate = new Date('2017-12-25')
NOTE: dueDate field was stored at firebase with a Date() object. e.g.: this.doc.dueDate = new Date('2017-12-25')
更多推荐
Firestore 按日期范围查询
发布评论