collection
*
Random_Id1
*amount:100
*name:John
Random_Id2
*amount:150
*name:Matt
Random_Id3
*amount:65
*name:Alice
I have a firestore collection that has different documents under it. these documents have data within them(name,age,amount, etc.). is there a way i can return the highest or Maximum amount in the collection? I'm implementing this in java(android). In the case of the above structure, the Maximum will be 150. Thank you in advance
While not a hard limit, if you sustain more than 1,000 writes per second, your write activity may be rate-limited. 256 MB from the REST API; 16 MB from the SDKs. The total data in each write operation should be less than 256 MB. Multi-path updates are subject to the same size limitation.
Storage for your Hosting content is at no cost up to 10 GB. If you are not on the Blaze plan, and you reach the 10 GB limit of no-cost Hosting storage, you won't be able to deploy new content to your sites.
Queries with limited sorting and filtering functionality can be performed with the firebase database. Cloud firestore assures automatic scaling and can handle 1 million concurrent connections and 10,000 writes/second.
You have to use a query that is defined via a combination of orderBy()
and limit()
, as follows:
CollectionReference collectionRef = db.collection("collection");
Query query = collectionRef.orderBy("amount", descending: true).limit(1);
See the docs here https://firebase.google.com/docs/firestore/query-data/queries and here https://firebase.google.com/docs/firestore/query-data/order-limit-data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With