Sami Karaeen
Sami Karaeen

Reputation: 23

How to aggregate queries in firebase

when i used to work with Ms SQL server i used to create for example this query

Select Sum(Amount * Price) from table 

How can we run such queries and how complex it can be

I relay need to either choose fire base or use normal SQL server to work on the project

Thanks

Upvotes: 1

Views: 2278

Answers (1)

ersin-ertan
ersin-ertan

Reputation: 2301

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 provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group.

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 does not support the following types of queries:

  • Queries with range filters on different fields, as described in the previous section.
  • Logical OR queries. In this case, you should create a separate query for each OR condition and merge the query results in your app.
  • Queries with a != clause. In this case, you should split the query into a greater-than query and a less-than query. For example, although the query clause where("age", "!=", "30") is not supported, you can get the same result set by combining two queries, one with the clause where("age", "<", "30") and one with the clause where("age", ">", 30).

Upvotes: 0

Related Questions