> For the complete documentation index, see [llms.txt](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/plugin-back-end-actions/firestore-backend/get-a-list-of-documents.md).

# Get a list of documents

This action performs a query to get a list of documents from a Firestore collection, according to the provided query filters.

***

## <mark style="color:blue;">Inputs and Settings</mark>

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FW4UTQ8cRjc0gX28hbCaW%2Fimage.png?alt=media&amp;token=2d4102e9-b28c-4fa9-b513-9729fe473524" alt=""><figcaption></figcaption></figure></div>

### Collection

The name or ID of the collection you want to get documents from.

### Query type

Either "list" or "count". This will define the type of query you want to perform and will affect which values will be returned from the backend operation.

### Query sort / order by options

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2Fkb4MPvnSCraST7BYtQLD%2Fimage.png?alt=media&amp;token=7c33c19a-19b9-46ef-bb43-e03b5bfbfd4e" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
This option will be ignored for "Count" query  types.
{% endhint %}

You can choose a field to order your list of document from, at query level, specifying the sort direction (descending = yes | ascending = no).

When doing a sorted query for the first time, you might be confronted with an alert asking you to create an index for that query. That's a Firestore feature that creates different indexes for the database, which makes queries lighting fast.

### Query filters (list) (count)

This options allow you to choose fields from which to filter your query.

#### Available query operators

You can read more on the [Cloud Firestore documentation](https://firebase.google.com/docs/firestore/query-data/queries#query_operators).

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FZzduHWvShdP2FWiBBVEB%2Fimage.png?alt=media&amp;token=3a6b00e0-85b3-4281-82a9-f9e9022dc45c" alt=""><figcaption><p>Query filter operators</p></figcaption></figure></div>

<table><thead><tr><th width="222">Operator</th><th>Description</th></tr></thead><tbody><tr><td>&#x3C;</td><td>Gets values less than the provided input (must be of type number or date)</td></tr><tr><td>&#x3C;=</td><td>Gets values less than or equal to the provided input (must be of type number or date)</td></tr><tr><td>==</td><td>Gets values equal to the provided input.</td></tr><tr><td>></td><td>Gets values greater than the provided input (must be of type number or date).</td></tr><tr><td>>=</td><td>Gets values greater than or equal to the provided input (must be of type number or date).</td></tr><tr><td>array-contains</td><td>Gets values where the field of type array/list has the value provided as input.</td></tr><tr><td>array-contains-any</td><td>Gets values where the field of type array/list any of the array of values provided as input.</td></tr><tr><td>in</td><td>Gets values where the field value is present on the array of values provided as input.</td></tr><tr><td>not-in</td><td>Gets values where the field value is not present on the array of values provided as input.</td></tr></tbody></table>

{% hint style="warning" %}
Firestore supports only one filter of type "array-contains", "array-contains-any", "in" or "not-in" per query. If you try to use more than one, the first one will be considered by the plugin, but the other's will be ignored.
{% endhint %}

{% hint style="warning" %}
Firestore does not offer "text" filters like the Bubble "contains keywords" option, because of the way they structure the database using indexes. For this kind os searches they recomend the use of external services like [Algolia](https://www.algolia.com/).
{% endhint %}

#### Types of filter values

Since Bubble is not flexible on the type of data we can define on plugins, the best way to implement our plugin was to work with texts. So each value you put on query values must be interpreted the right way to perform the Firestore Query. Defining a "query filter value type" can help us get it right.

So here are the types of query filter values:

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FgSrSn4QTUtXVZvfe8i3f%2Fimage.png?alt=media&amp;token=a1396fe3-bcce-4c81-952d-3f72882056de" alt=""><figcaption><p>Query filter value types</p></figcaption></figure></div>

<table><thead><tr><th width="185">Type</th><th>How it will be handled</th></tr></thead><tbody><tr><td>auto</td><td>The plugin will try to infer the type from the input you provided.</td></tr><tr><td>text</td><td>Treated as a text value.</td></tr><tr><td>number</td><td>Treated as a number value.</td></tr><tr><td>boolean (true/false)</td><td>Treated as a true or false (yes/no) value.</td></tr><tr><td>date</td><td>Treated as a Date type. The plugin will convert the value to a Date.</td></tr><tr><td>array</td><td>Treated as a list in JavaScript format (e.g. ["item1", "item2", "item3"]).<br>If you need to use it on Bubble's lists, you can apply the ":format as text" message to the list, to build the array string into that format.</td></tr><tr><td>reference (coll/doc_id)</td><td>Treated as a document reference.<br>Document references are always handled by the plugin as paths to a document. For instance, if you want to get the reference for a document from the "tasks" collection with an id "1234", you should right "tasks/1234"</td></tr></tbody></table>

{% hint style="info" %}
Arrays and lists are always handled in JavaScript notation, which means each value should be comma separated and must be between brackets.

An array of number should be provided as a text like: \[1, 3, 45, 2]

An array of texts should contain balues between quotes: \["text1", "text2", "text3"]
{% endhint %}

{% hint style="info" %}
Document references are always handled by the plugin as paths to a document. For instance, if you want to get the reference for a document from the "tasks" collection with an id "1234", you should right "tasks/1234"
{% endhint %}

***

## <mark style="color:blue;">Returned Values</mark>

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FvfxwomQMMQeQkOVZycvv%2Fimage.png?alt=media&amp;token=98e346fd-afc0-4e18-bd57-b94985ac43e2" alt=""><figcaption></figcaption></figure></div>

### List of documents

A list of document JSON strings, that can be provided to repeating groups and then, on each cell, extracted through a Firestore Data Extractor to get the values from the document fields.

### Docs IDs

A list of texts contains the IDs of the document fetched from a "List" or "List and Count" type of queries.

### Field Value Lists (1, 2, 3...)

Lists of fields you chose to retrieve from the documents list, with filters already applied.

### Count

If the type of query is "count", this state will store the result of the couting operation.

{% hint style="info" %}
On Firestore, on the count operation, each 1000 documents will account for 1 document read.
{% endhint %}
