【发布时间】:2019-03-06 18:00:31
【问题描述】:
我在 Firestore 中有以下数据结构
- runners (Collection)
-- uid_1 (Document)
--- name: James
--- height: 170
--- weight: 54
--- runTimeInSeconds: [ 540, 533, 530, 500 ] // this is array of 4
-- uid_2 (Document)
--- name: Larry
--- height: 168
--- weight: 51
--- runTimeInSeconds: [ 521, 611, 501 ] // this is array of 3 runs
-- uid_3 (Document)
--- name: Ben
--- height: 180
--- weight: 76
--- runTimeInSeconds: [ 621, 533 ] // this is array of 2 runs
我想按此顺序获取以下文档(runTimeInSeconds 大于 600): uid_2 后跟 uid 3。但我不想看到 uid_1。
我应该编写什么 firestore 查询?
我试过了:
runnersRef.where("runTimeInSeconds", ">", 600) // this does not work.
【问题讨论】:
-
您是在问您提出的查询是否有效?您是否尝试过仅运行它以查看它是否有效?
-
@DougStevenson 我的意思是问我应该写什么firestore查询。
-
嗯,看起来您之前写过一篇,然后从问题中删除了它。它没有工作吗?看起来它会起作用的。如果您不清楚如何查询 Firestore,您应该从文档开始,而不是在 Stack Overflow 上询问。 firebase.google.com/docs/firestore/query-data/queries
-
@DougStevenson 我试过了。它似乎没有用。很奇怪。
-
@DougStevenson 它不工作。你可以查看stackblitz.com/edit/…,我该怎么做才能让它工作?
标签: firebase google-cloud-firestore