Firestore 按日期范围查询

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

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

发布评论

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

>www.elefans.com

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