如何在firebase中聚合查询 [英] How to aggregate queries in firebase
问题描述
当我过去使用 Ms SQL 服务器时,我曾经创建过例如这个查询
when i used to work with Ms SQL server i used to create for example this query
Select Sum(Amount * Price) from table
- 这是否可以在 GOOGLE FIRE BASE 中完成,这在我开始新项目之前非常重要
- 注意会有更多这样的查询
- 对不同字段使用范围过滤器的查询,如上一节所述.
- 逻辑 OR 查询.在这种情况下,您应该为每个 OR 条件创建一个单独的查询,并在您的应用中合并查询结果.
- 带有 != 子句的查询.在这种情况下,您应该将查询拆分为大于查询和小于查询.例如,虽然不支持查询子句 where("age", "!=", "30"),但是可以通过组合两个查询来得到相同的结果集,一个带有子句 where("age", "<", "30") 和一个带有 where("age", ">", 30).
我们如何运行这样的查询以及它有多复杂
How can we run such queries and how complex it can be
我需要选择fire base或者使用普通的SQL server来处理这个项目
I relay need to either choose fire base or use normal SQL server to work on the project
谢谢
推荐答案
Cloud Firestore 不支持原生聚合查询.但是,您可以使用客户端事务或云函数来轻松维护聚合关于您的数据的信息.
Cloud Firestore does not support native aggregation queries. However, you can use client-side transactions or Cloud Functions to easily maintain aggregate information about your data.
Cloud Firestore 提供强大的查询功能,用于指定您需要哪些文档想要从集合或集合组中检索.
Cloud Firestore provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group.
您还可以链接多个 where() 方法来创建更具体的查询(逻辑与).但是,要将相等运算符 (==) 与范围或数组包含子句(<、<=、>、>= 或数组包含
You can also chain multiple where() methods to create more specific queries (logical AND). However, to combine the equality operator (==) with a range or array-contains clause (<, <=, >, >=, or array-contains
Cloud Firestore 不支持以下类型的查询:一个>
这篇关于如何在firebase中聚合查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!