Count a list of documents

This action performs an aggregation operation on a Firestore collection, counting the number of document according to the provided query filters.


Inputs and Settings

Collection

The name or ID of the collection you want to count document from.

Query filters

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.

Query filter operators
Operator
Description

<

Gets values less than the provided input (must be of type number or date)

<=

Gets values less than or equal to the provided input (must be of type number or date)

==

Gets values equal to the provided input.

>

Gets values greater than the provided input (must be of type number or date).

>=

Gets values greater than or equal to the provided input (must be of type number or date).

array-contains

Gets values where the field of type array/list has the value provided as input.

array-contains-any

Gets values where the field of type array/list any of the array of values provided as input.

in

Gets values where the field value is present on the array of values provided as input.

not-in

Gets values where the field value is not present on the array of values provided as input.

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:

Query filter value types
Type
How it will be handled

auto

The plugin will try to infer the type from the input you provided.

text

Treated as a text value.

number

Treated as a number value.

boolean (true/false)

Treated as a true or false (yes/no) value.

date

Treated as a Date type. The plugin will convert the value to a Date.

array

Treated as a list in JavaScript format (e.g. ["item1", "item2", "item3"]). 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.

reference (coll/doc_id)

Treated as a document reference. 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"

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"]

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"


Returned Values

Count

The resulting number, with the number of documents for the given query.

On Firestore, on the count operation, each 1000 documents will account for 1 document read.

Last updated