Leo*_*aus 1 javascript node.js firebase google-cloud-functions google-cloud-firestore
FieldValue.serverTimestamp()我正在寻找正确的语法来获取时间戳字段 ( ) 已存在 x 天的文档的 documentSnapshot 。
例如:在我的集合中,每个文档都有时间戳字段“ createdAt”。createdAt"我有一个每日计划的云功能,可以获取并记录“”超过 5 天的所有文档。
我的目标是哪种语法?
您可以使用日期对象通过比较来过滤查询:
const date = new Date(Date.now() - x * 24 * 60 * 60 * 1000) // x days ago
collectionRef.where('createdAt', '<', date)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
783 次 |
| 最近记录: |