#List all documents from Firestore

1 messages · Page 1 of 1 (latest)

celest crag
#

I'm trying to List Documents for a Firestore query and get all documents in the collection but there seems be a limit of 10 documents placed even when the Limit field is not set to a value. There are around 100 documents in the collection I'm trying to list.

How can I list all the documents from a Firestore collection?

Using Appsmith v1.9.43

civic bearBOT
#

Hey There,

We've registered your query, and our team will get back to you soon.

Regards,
Pranav

#

Hello!

The default is 10, but you can specify as many as you like. We do this because
app performance can suffer if a user pulls too much data, and in those cases we
encourage the use of server-side pagination. If you need all of the data at once
then setting the limit to 200 should work for your use case, but please keep in
mind that if your data grows you may want to consider paginated or filtered
queries to maintain the performance of your app.

Thank you for your ongoing support and patience. We aim to provide you with
helpful assistance and hope we have addressed your question adequately.

Please take a moment to share your experience with our support team.
https://survey.frontapp.com/v2/09a400bf433bc9676d67/5dace41715dd3ebb2f17c87c3be7582c

celest crag
civic bearBOT
#

Hello, I'm AppySmith, your support bot with a knack for Appsmith tips! To count
Firestore documents or build aggregation queries within Appsmith, you would
generally follow these steps: 1. Use a Firestore plugin to connect your
Firestore database. 2. Write the query you need, using Firestore's query
language or applicable methods. 3. Firestore does not directly support count
queries, however, you can use the client to retrieve documents and then count
them in Appsmith using JavaScript. For counting documents, you can do this: -
Retrieve documents based on your query. - Use a JavaScript function within
Appsmith to count the documents. For aggregation queries, Firestore has
limitations and does not support the aggregation out-of-the-box like SQL
databases do. However, you can: - Retrieve the documents that you want to
aggregate. - Perform the aggregation client-side in Appsmith using JavaScript.
If you have a specific query or need further guidance on setting up aggregation
queries within Appsmith, including using Firestore, please let me know, and I
can provide more detailed instructions. If you don't find my response helpful,
you can request to speak to a human agent

celest crag
#

can you provide some sample code?

#

Is it possible to count how many firestore documents there are in total in a collection?

civic bearBOT
#

Certainly! Below is a sample JavaScript snippet that you could use in Appsmith
to count the number of documents retrieved from a Firestore query: Firstly, you
would set up your Firestore datasource and create a query to fetch documents.
Once you have the query in place, you can use a JavaScript function to process
the result. javascript // Assume you have a Firestore query named `GetDocuments` const documents = GetDocuments.data; // This will depend on the actual name of your query if (documents) { const count = documents.length; // Count the number of documents return count; } else { return 0; // In case there are no documents or an error occurred } To perform a basic aggregation such
as summing up a particular field, you could use something like this:

'value' field. const documents = GetDocuments.data [http://GetDocuments.data];
if (documents) { const totalSum = documents.reduce((sum, doc) => sum +
(doc.value || 0), 0); return totalSum; } else { return 0; } ``` In these
snippets, replace `GetDocuments.data` with the actual data property from your
Firestore query in Appsmith. Please note that these are simple JavaScript-based
operations that run on the client side. They will be effective for small to
medium-sized data sets. Firestore itself doesn't support these operations
server-side, so if you have a large dataset, you might need to consider
implementing a cloud function that performs the aggregation on the server side
and returns the result, or alternatively, maintain a counter or aggregate field
that is updated transactionally on write operations. If you don't find my
response helpful, you can request to speak to a human agent
celest crag
#

is there a way to write raw firestore queries in appsmith rather than using the gui?