本文介绍了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", (而不是字符串或数字),我这样做是为了获得到期日为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按日期范围查询
发布评论