Firestore按日期范围查询

编程入门 行业动态 更新时间:2024-10-26 14:39:20
本文介绍了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按日期范围查询

本文发布于:2023-10-28 23:11:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按日   Firestore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!