Debugging functions Stay organized with collections Save and categorize content based on your preferences.
Debugging Functions
| Name | Description |
EXISTS | ReturnsTRUE if the value is not an absent value |
IS_ABSENT | ReturnsTRUE if the value is an absent value |
IF_ABSENT | Replaces the value with an expression if it is absent |
IS_ERROR | Catches and checks if an error has been thrown by the underlying expression |
IF_ERROR | Replaces the value with an expression if it has thrown an error |
EXISTS
Syntax:
exists(value: ANY) -> BOOLEANDescription:
ReturnsTRUE ifvalue is not the absent value.
Examples:
value | exists(value) |
|---|---|
| 0L | TRUE |
| "foo" | TRUE |
NULL | TRUE |
ABSENT | FALSE |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("rating").exists().as("hasRating")).execute();
Web
Example:
constresult=awaitexecute(db.pipeline().collection("books").select(field("rating").exists().as("hasRating")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("rating").exists().as("hasRating")]).execute()
Kotlin
Example:
valresult=db.pipeline().collection("books").select(field("rating").exists().alias("hasRating")).execute()
Java
Example:
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("rating").exists().alias("hasRating")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("rating").exists().as_("hasRating")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(exists(field("rating")).as("hasRating")).execute().get();
IS_ABSENT
Syntax:
is_absent(value: ANY) -> BOOLEANDescription:
ReturnsTRUE ifvalue is the absent value, andFALSE otherwise. Absent valuesare values that are missing from the input, such as a missing document field.
Examples:
value | is_absent(value) |
|---|---|
| 0L | FALSE |
| "foo" | FALSE |
NULL | FALSE |
ABSENT | TRUE |
IF_ABSENT
Syntax:
if_absent(value: ANY, replacement: ANY) -> ANYDescription:
Ifvalue is an absent value, evaluates and returnsreplacement. Otherwise returnsvalue.
Examples:
value | replacement | if_absent(value, replacement) |
|---|---|---|
| 5L | 0L | 5L |
NULL | 0L | NULL |
ABSENT | 0L | 0L |
IS_ERROR
Syntax:
is_error(try: ANY) -> BOOLEANDescription:
ReturnsTRUE if an error is thrown during the evaluation oftry. ReturnsFALSE otherwise.
IF_ERROR
Syntax:
if_error(try: ANY, catch: ANY) -> ANYDescription:
If an error is thrown during the evaluation oftry, evaluates and returnsreplacement. Otherwise returns the resolved value oftry.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.