디버깅 함수

디버깅 함수

이름 설명
EXISTS 값이 누락된 값이 아니면 TRUE를 반환합니다.
IS_ABSENT 값이 누락된 값인 경우 TRUE를 반환합니다.
IF_ABSENT 값이 누락된 경우 표현식으로 값을 대체합니다.
IS_ERROR 기본 표현식에서 오류가 발생했는지 포착하고 확인합니다.
IF_ERROR 오류가 발생한 경우 값을 표현식으로 바꿉니다.

EXISTS

구문:

exists(value: ANY) -> BOOLEAN

설명:

value가 누락된 값이 아니면 TRUE를 반환합니다.

예:

value exists(value)
0L TRUE
'foo' TRUE
NULL TRUE
ABSENT FALSE
Node.js

예:

const results = await db.pipeline()
  .collection("customers")
  .select(exists(Field.of("orders")))
  .execute();
    

Web

예:

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("rating").exists().as("hasRating"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("rating").exists().as("hasRating")])
  .execute()

Kotlin

예:

val result = db.pipeline()
    .collection("books")
    .select(field("rating").exists().alias("hasRating"))
    .execute()

Java

예:

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("rating").exists().alias("hasRating"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").exists().as_("hasRating"))
    .execute()
)

IS_ABSENT

구문:

is_absent(value: ANY) -> BOOLEAN

설명:

value가 누락된 값이면 TRUE를 반환하고, 그렇지 않으면 FALSE를 반환합니다. 누락된 값은 문서 필드 누락과 같이 입력에서 누락된 값입니다.

예:

value is_absent(value)
0L FALSE
'foo' FALSE
NULL FALSE
ABSENT TRUE

IF_ABSENT

구문:

if_absent(value: ANY, replacement: ANY) -> ANY

설명:

value가 누락된 값인 경우 평가하여 replacement를 반환합니다. 그렇지 않으면 value를 반환합니다.

예:

value replacement if_absent(value, replacement)
5L 0L 5L
NULL 0L NULL
ABSENT 0L 0L

IS_ERROR

구문:

is_error(try: ANY) -> BOOLEAN

설명:

try 평가 중에 오류가 발생하면 TRUE를 반환합니다. 그 밖의 경우에는 FALSE를 반환합니다.

IF_ERROR

구문:

if_error(try: ANY, catch: ANY) -> ANY

설명:

try 평가 중에 오류가 발생하면 replacement를 평가하고 반환합니다. 그렇지 않으면 try의 확인된 값을 반환합니다.