دوال الكتابة

دوال النوع

الاسم الوصف
TYPE لعرض نوع القيمة كـ STRING.
IS_TYPE تعرض الدالة true إذا كانت القيمة تتطابق مع النوع المحدّد.

النوع

البنية:

type(input: ANY) -> STRING

الوصف:

تعرض هذه الدالة تمثيلاً كسلسلة للنوع input.

إذا تم تقديم قيمة غير متوفّرة، يتم عرض NULL.

أمثلة:

input type(input)
فارغ "null"
صحيح "boolean"
1 "int32"
-3L "int64"
3.14 "float64"
‫2024-01-01T00:00:00Z بالتوقيت العالمي المتفق عليه "timestamp"
"foo" "string"
b"foo" "بايت"
[1, 2] "array"
{‎"a": 1} "map"
path("c/d") "reference"
vector([1.0, 2.0]) "vector"
ABSENT فارغ

أمثلة على العملاء

Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("title").notEqual("1984").as("not1984"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("title").notEqual("1984").as("not1984"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("title").notEqual("1984").as("not1984")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("title").notEqual("1984").alias("not1984"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("title").not_equal("1984").as_("not1984"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(notEqual(field("title"), "1984").as("not1984"))
        .execute()
        .get();

IS_TYPE

البنية:

is_type(input: ANY, type: STRING) -> BOOLEAN

الوصف:

تعرض الدالة true إذا كان input مطابقًا لـ type المحدّد، وإلا تعرض false. إذا تم تقديم قيمة input غير متوفّرة، يتم عرض NULL.

سلاسل type المتاحة هي:

  • "null"
  • "boolean"
  • "int32"
  • "int64"
  • "float64"
  • "decimal128"
  • "number"
  • "timestamp"
  • "string"
  • "bytes"
  • "array"
  • "map"
  • "reference"
  • "vector"
  • "geo_point"
  • "max_key"
  • "min_key"
  • "object_id"
  • "regex"
  • "bson_timestamp"

أمثلة:

input type is_type(input, type)
فارغ "null" صحيح
صحيح "boolean" صحيح
3.14 "float64" صحيح
"foo" "string" صحيح
b"foo" "string" خطأ
[1, 2] "array" صحيح
{‎"a": 1} "map" صحيح
vector([1.0, 2.0]) "vector" صحيح
ABSENT "string" فارغ
"bar" "غير ذلك" خطأ