Tüm işlevler

Toplu

Tüm toplama işlevleri, aggregate(...) aşamasında üst düzey ifadeler olarak kullanılabilir.

Ad Açıklama
COUNT Belge sayısını döndürür.
COUNT_IF Bir ifadenin TRUE olarak değerlendirildiği dokümanların sayısını döndürür.
COUNT_DISTINCT Benzersiz ve boş olmayan NULL değerlerin sayısını döndürür.
SUM Tüm NUMERIC değerlerinin toplamını döndürür.
AVERAGE Tüm NUMERIC değerlerinin ortalamasını döndürür.
MINIMUM NULL olmayan minimum değeri döndürür.
MAXIMUM Maksimum NULL olmayan değeri döndürür.
FIRST İlk dokümanın expression değerini döndürür.
LAST Son belgenin expression değerini döndürür.
ARRAY_AGG Tüm giriş değerlerinin dizisini döndürür.
ARRAY_AGG_DISTINCT Tüm farklı giriş değerlerinin dizisini döndürür.

COUNT

Söz dizimi:

count() -> INT64
count(expression: ANY) -> INT64

Açıklama:

expression, NULL dışındaki herhangi bir değer olarak değerlendirildiğinde önceki aşamadaki dokümanların sayısını döndürür. expression sağlanmazsa önceki aşamadaki toplam belge sayısını döndürür.

Node.js
// Total number of books in the collection
const countOfAll = await db.pipeline()
  .collection("books")
  .aggregate(countAll().as("count"))
  .execute();

// Number of books with nonnull `ratings` field
const countField = await db.pipeline()
  .collection("books")
  .aggregate(field("ratings").count().as("count"))
  .execute();

Web

// Total number of books in the collection
const countOfAll = await execute(db.pipeline()
  .collection("books")
  .aggregate(countAll().as("count"))
);

// Number of books with nonnull `ratings` field
const countField = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("ratings").count().as("count"))
);
Swift
// Total number of books in the collection
let countAll = try await db.pipeline()
  .collection("books")
  .aggregate([CountAll().as("count")])
  .execute()

// Number of books with nonnull `ratings` field
let countField = try await db.pipeline()
  .collection("books")
  .aggregate([Field("ratings").count().as("count")])
  .execute()

Kotlin

// Total number of books in the collection
val countAll = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.countAll().alias("count"))
    .execute()

// Number of books with nonnull `ratings` field
val countField = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.count("ratings").alias("count"))
    .execute()

Java

// Total number of books in the collection
Task<Pipeline.Snapshot> countAll = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.countAll().alias("count"))
    .execute();

// Number of books with nonnull `ratings` field
Task<Pipeline.Snapshot> countField = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.count("ratings").alias("count"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Count

# Total number of books in the collection
count_all = (
    client.pipeline().collection("books").aggregate(Count().as_("count")).execute()
)

# Number of books with nonnull `ratings` field
count_field = (
    client.pipeline()
    .collection("books")
    .aggregate(Count("ratings").as_("count"))
    .execute()
)
Java
// Total number of books in the collection
Pipeline.Snapshot countAll =
    firestore.pipeline().collection("books").aggregate(countAll().as("count")).execute().get();

// Number of books with nonnull `ratings` field
Pipeline.Snapshot countField =
    firestore
        .pipeline()
        .collection("books")
        .aggregate(count("ratings").as("count"))
        .execute()
        .get();

COUNT_IF

Söz dizimi:

count_if(expression: BOOLEAN) -> INT64

Açıklama:

expression ifadesinin TRUE olarak değerlendirildiği önceki aşamadaki belge sayısını döndürür.

Node.js
const result = await db.pipeline()
  .collection("books")
  .aggregate(
    field("rating").greaterThan(4).countIf().as("filteredCount")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(
    field("rating").greaterThan(4).countIf().as("filteredCount")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .aggregate([
    AggregateFunction("count_if", [Field("rating").greaterThan(4)]).as("filteredCount")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .aggregate(
        AggregateFunction.countIf(field("rating").greaterThan(4)).alias("filteredCount")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .aggregate(
        AggregateFunction.countIf(field("rating").greaterThan(4)).alias("filteredCount")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .aggregate(Field.of("rating").greater_than(4).count_if().as_("filteredCount"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .aggregate(countIf(field("rating").greaterThan(4)).as("filteredCount"))
        .execute()
        .get();

COUNT_DISTINCT

Söz dizimi:

count_distinct(expression: ANY) -> INT64

Açıklama:

expression değerinin benzersiz, NULL olmayan ve ABSENT olmayan değerlerinin sayısını döndürür.

Node.js
const result = await db.pipeline()
  .collection("books")
  .aggregate(field("author").countDistinct().as("unique_authors"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("author").countDistinct().as("unique_authors"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .aggregate([AggregateFunction("count_distinct", [Field("author")]).as("unique_authors")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.countDistinct("author").alias("unique_authors"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.countDistinct("author").alias("unique_authors"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .aggregate(Field.of("author").count_distinct().as_("unique_authors"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .aggregate(countDistinct("author").as("unique_authors"))
        .execute()
        .get();

TOPLA

Söz dizimi:

sum(expression: ANY) -> NUMBER

Açıklama:

Sayısal olmayan değerleri yoksayarak tüm sayısal değerlerin toplamını döndürür. Değerlerden herhangi biri NaN ise NaN değerini döndürür.

Çıkış, aşağıdaki durumlar hariç en geniş giriş türüyle aynı türde olur:

  • INTEGER olarak gösterilemeyen bir INTEGER, DOUBLE'ye dönüştürülür.
Node.js
const result = await db.pipeline()
  .collection("cities")
  .aggregate(field("population").sum().as("totalPopulation"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("cities")
  .aggregate(field("population").sum().as("totalPopulation"))
);
Swift
let result = try await db.pipeline()
  .collection("cities")
  .aggregate([Field("population").sum().as("totalPopulation")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("cities")
    .aggregate(AggregateFunction.sum("population").alias("totalPopulation"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("cities")
    .aggregate(AggregateFunction.sum("population").alias("totalPopulation"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("cities")
    .aggregate(Field.of("population").sum().as_("totalPopulation"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("cities")
        .aggregate(sum("population").as("totalPopulation"))
        .execute()
        .get();

ORTALAMA

Söz dizimi:

average(expression: ANY) -> FLOAT64

Açıklama:

Sayısal olmayan değerleri yoksayarak tüm sayısal değerlerin ortalamasını döndürür. Değerlerden herhangi biri NaN ise NaN, sayısal değerler toplanmamışsa NULL olarak değerlendirilir.

Çıkış, aşağıdaki durumlar hariç giriş türüyle aynı türde olur:

  • INTEGER olarak gösterilemeyen bir INTEGER, DOUBLE'ye dönüştürülür.
Node.js
const result = await db.pipeline()
  .collection("cities")
  .aggregate(field("population").average().as("averagePopulation"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("cities")
  .aggregate(field("population").average().as("averagePopulation"))
);
Swift
let result = try await db.pipeline()
  .collection("cities")
  .aggregate([Field("population").average().as("averagePopulation")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("cities")
    .aggregate(AggregateFunction.average("population").alias("averagePopulation"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("cities")
    .aggregate(AggregateFunction.average("population").alias("averagePopulation"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("cities")
    .aggregate(Field.of("population").average().as_("averagePopulation"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("cities")
        .aggregate(average("population").as("averagePopulation"))
        .execute()
        .get();

MİNİMUM

Söz dizimi:

minimum(expression: ANY) -> ANY

Açıklama:

Her belgede değerlendirildiğinde NULL olmayan ve mevcut olmayan expression değerinin minimum değerini döndürür.

NULL olmayan ve eksik olmayan değer yoksa NULL döndürülür. Hiçbir dokümanın dikkate alınmadığı durumlar da buna dahildir.

Birden fazla minimum eşdeğer değer varsa bu değerlerden herhangi biri döndürülebilir. Değer türü sıralaması, belgelenen sıralamaya göre yapılır.

Node.js
const result = await db.pipeline()
  .collection("books")
  .aggregate(field("price").minimum().as("minimumPrice"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("price").minimum().as("minimumPrice"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .aggregate([Field("price").minimum().as("minimumPrice")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.minimum("price").alias("minimumPrice"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.minimum("price").alias("minimumPrice"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .aggregate(Field.of("price").minimum().as_("minimumPrice"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .aggregate(minimum("price").as("minimumPrice"))
        .execute()
        .get();

MAKSİMUM

Söz dizimi:

maximum(expression: ANY) -> ANY

Açıklama:

Her belgede değerlendirildiğinde expression öğesinin maksimum NULL olmayan, eksik olmayan değerini döndürür.

NULL olmayan ve eksik olmayan değer yoksa NULL döndürülür. Hiçbir dokümanın dikkate alınmadığı durumlar da buna dahildir.

Birden fazla maksimum eşdeğer değer varsa bu değerlerden herhangi biri döndürülebilir. Değer türü sıralaması, belgelenen sıralamaya göre yapılır.

Node.js
const result = await db.pipeline()
  .collection("books")
  .aggregate(field("price").maximum().as("maximumPrice"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("price").maximum().as("maximumPrice"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .aggregate([Field("price").maximum().as("maximumPrice")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.maximum("price").alias("maximumPrice"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .aggregate(AggregateFunction.maximum("price").alias("maximumPrice"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .aggregate(Field.of("price").maximum().as_("maximumPrice"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .aggregate(maximum("price").as("maximumPrice"))
        .execute()
        .get();

FIRST

Söz dizimi:

first(expression: ANY) -> ANY

Açıklama:

Döndürülen ilk doküman için expression değerini döndürür.

SON

Söz dizimi:

last(expression: ANY) -> ANY

Açıklama:

Son döndürülen doküman için expression değerini döndürür.

ARRAY_AGG

Söz dizimi:

array_agg(expression: ANY) -> ARRAY<ANY>

Açıklama:

Her belgede değerlendirildiğinde expression değerlerinin tümünü içeren bir dizi döndürür.

İfade, mevcut olmayan bir değere çözümlenirse NULL değerine dönüştürülür.

Çıkış dizisindeki öğelerin sırası sabit değildir ve bu sıraya güvenilmemelidir.

ARRAY_AGG_DISTINCT

Söz dizimi:

array_agg_distinct(expression: ANY) -> ARRAY<ANY>

Açıklama:

Her belgede değerlendirildiğinde expression öğesinin tüm farklı değerlerini içeren bir dizi döndürür.

İfade, mevcut olmayan bir değere çözümlenirse NULL değerine dönüştürülür.

Çıkış dizisindeki öğelerin sırası sabit değildir ve bu sıraya güvenilmemelidir.

Aritmetik İşlevler

Cloud Firestore içindeki tüm aritmetik işlevler aşağıdaki davranışlara sahiptir:

  • Giriş parametrelerinden herhangi biri NULL ise NULL olarak değerlendirilir.
  • Bağımsız değişkenlerden herhangi biri NaN ise NaN olarak değerlendirilir.
  • Taşma veya eksiklik oluşursa hata oluşturur.

Ayrıca, bir aritmetik işlev farklı türlerde birden fazla sayısal bağımsız değişken aldığında (örneğin: add(5.0, 6)), Cloud Firestore bağımsız değişkenleri en geniş giriş türüne dönüştürür. Yalnızca INT32 girişleri sağlanırsa dönüş türü INT64 olur.

Ad Açıklama
ABS number değerinin mutlak değerini döndürür.
ADD x + y değerini döndürür.
SUBTRACT x - y değerini döndürür.
MULTIPLY x * y değerini döndürür.
DIVIDE x / y değerini döndürür.
MOD x / y bölme işleminin kalanını döndürür.
CEIL number sayısının tavanını döndürür.
FLOOR number değerinin tabanını döndürür.
ROUND number sayısını places ondalık basamağa yuvarlar.
TRUNC number sayısını places ondalık basamağa kadar keser.
POW base^exponent değerini döndürür.
SQRT number sayısının karekökünü döndürür.
EXP Euler sayısını exponent kuvvetine yükseltilmiş olarak döndürür.
LN a'nın doğal logaritmasını döndürür. number
LOG number sayısının logaritmasını döndürür.
LOG10 number sayısının 10 tabanındaki logaritmasını döndürür.
RAND Sözde rastgele bir kayan nokta sayısı döndürür.

ABS

Söz dizimi:

abs[N <: INT32 | INT64 | FLOAT64](number: N) -> N

Açıklama:

number değerinin mutlak değerini döndürür.

  • İşlev, INT32 veya INT64 değerini taşırsa hata verir.

Örnekler:

sayı abs(number)
10 10
-10 10
10L 10L
-0,0 0,0
10.5 10.5
-10.5 10.5
-231 [error]
-263 [error]

EKLE

Söz dizimi:

add[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N

Açıklama:

x + y değerini döndürür.

Örnekler:

x y add(x, y)
20 3 23
10.0 1 11.0
22,5 2.0 24,5
INT64.MAX 1 [error]
INT64.MIN -1 [error]
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("soldBooks").add(field("unsoldBooks")).as("totalBooks"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("soldBooks").add(field("unsoldBooks")).as("totalBooks"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("soldBooks").add(Field("unsoldBooks")).as("totalBooks")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(Expression.add(field("soldBooks"), field("unsoldBooks")).alias("totalBooks"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(Expression.add(field("soldBooks"), field("unsoldBooks")).alias("totalBooks"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("soldBooks").add(Field.of("unsoldBooks")).as_("totalBooks"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(add(field("soldBooks"), field("unsoldBooks")).as("totalBooks"))
        .execute()
        .get();

SUBTRACT

Söz dizimi:

subtract[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N

Açıklama:

x - y değerini döndürür.

Örnekler:

x y subtract(x, y)
20 3 17
10.0 1 9.0
22,5 2.0 20,5
INT64.MAX -1 [error]
INT64.MIN 1 [error]
Node.js
const storeCredit = 7;
const result = await db.pipeline()
  .collection("books")
  .select(field("price").subtract(constant(storeCredit)).as("totalCost"))
  .execute();

Web

const storeCredit = 7;
const result = await execute(db.pipeline()
  .collection("books")
  .select(field("price").subtract(constant(storeCredit)).as("totalCost"))
);
Swift
let storeCredit = 7
let result = try await db.pipeline()
  .collection("books")
  .select([Field("price").subtract(Constant(storeCredit)).as("totalCost")])
  .execute()

Kotlin

val storeCredit = 7
val result = db.pipeline()
    .collection("books")
    .select(Expression.subtract(field("price"), storeCredit).alias("totalCost"))
    .execute()

Java

int storeCredit = 7;
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(Expression.subtract(field("price"), storeCredit).alias("totalCost"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

store_credit = 7
result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("price").subtract(store_credit).as_("totalCost"))
    .execute()
)
Java
int storeCredit = 7;
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(subtract(field("price"), storeCredit).as("totalCost"))
        .execute()
        .get();

MULTIPLY

Söz dizimi:

multiply[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N

Açıklama:

x * y değerini döndürür.

Örnekler:

x y multiply(x, y)
20 3 60
10.0 1 10.0
22,5 2.0 45,0
INT64.MAX 2 [error]
INT64.MIN 2 [error]
FLOAT64.MAX FLOAT64.MAX +inf
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("price").multiply(field("soldBooks")).as("revenue"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("price").multiply(field("soldBooks")).as("revenue"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("price").multiply(Field("soldBooks")).as("revenue")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(Expression.multiply(field("price"), field("soldBooks")).alias("revenue"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(Expression.multiply(field("price"), field("soldBooks")).alias("revenue"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("price").multiply(Field.of("soldBooks")).as_("revenue"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(multiply(field("price"), field("soldBooks")).as("revenue"))
        .execute()
        .get();

DIVIDE

Söz dizimi:

divide[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N

Açıklama:

x / y değerini döndürür. Tam sayı bölme işlemi kesilir.

Örnekler:

x y divide(x, y)
20 3 6
10.0 3 3,333...
22,5 2 11,25
10 0 [error]
1.0 0,0 +inf
-1,0 0,0 -inf
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("ratings").divide(field("soldBooks")).as("reviewRate"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("ratings").divide(field("soldBooks")).as("reviewRate"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("ratings").divide(Field("soldBooks")).as("reviewRate")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(Expression.divide(field("ratings"), field("soldBooks")).alias("reviewRate"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(Expression.divide(field("ratings"), field("soldBooks")).alias("reviewRate"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("ratings").divide(Field.of("soldBooks")).as_("reviewRate"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(divide(field("ratings"), field("soldBooks")).as("reviewRate"))
        .execute()
        .get();

MOD

Söz dizimi:

mod[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N

Açıklama:

x / y değerinin kalanını döndürür.

  • Tam sayı türleri (INT64) için y sıfır olduğunda error istisnası oluşturur.
  • Kayan noktalı türler (FLOAT64) için y sıfır olduğunda NaN değerini döndürür.

Örnekler:

x y mod(x, y)
20 3 2
-10 3 -1
10 -3 1
-10 -3 -1
10 1 0
22,5 2 0.5
22,5 0,0 NaN
25 0 [error]
Node.js
const displayCapacity = 1000;
const result = await db.pipeline()
  .collection("books")
  .select(field("unsoldBooks").mod(constant(displayCapacity)).as("warehousedBooks"))
  .execute();

Web

const displayCapacity = 1000;
const result = await execute(db.pipeline()
  .collection("books")
  .select(field("unsoldBooks").mod(constant(displayCapacity)).as("warehousedBooks"))
);
Swift
let displayCapacity = 1000
let result = try await db.pipeline()
  .collection("books")
  .select([Field("unsoldBooks").mod(Constant(displayCapacity)).as("warehousedBooks")])
  .execute()

Kotlin

val displayCapacity = 1000
val result = db.pipeline()
    .collection("books")
    .select(Expression.mod(field("unsoldBooks"), displayCapacity).alias("warehousedBooks"))
    .execute()

Java

int displayCapacity = 1000;
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(Expression.mod(field("unsoldBooks"), displayCapacity).alias("warehousedBooks"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

display_capacity = 1000
result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("unsoldBooks").mod(display_capacity).as_("warehousedBooks"))
    .execute()
)
Java
int displayCapacity = 1000;
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(mod(field("unsoldBooks"), displayCapacity).as("warehousedBooks"))
        .execute()
        .get();

CEIL

Söz dizimi:

ceil[N <: INT32 | INT64 | FLOAT64](number: N) -> N

Açıklama:

number değerinden küçük olmayan en küçük tam sayı değerini döndürür.

Örnekler:

sayı ceil(number)
20 20
10 10
0 0
24L 24L
-0,4 -0,0
0,4 1.0
22,5 23,0
+inf +inf
-inf -inf
Node.js
const booksPerShelf = 100;
const result = await db.pipeline()
  .collection("books")
  .select(
    field("unsoldBooks").divide(constant(booksPerShelf)).ceil().as("requiredShelves")
  )
  .execute();

Web

const booksPerShelf = 100;
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("unsoldBooks").divide(constant(booksPerShelf)).ceil().as("requiredShelves")
  )
);
Swift
let booksPerShelf = 100
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("unsoldBooks").divide(Constant(booksPerShelf)).ceil().as("requiredShelves")
  ])
  .execute()

Kotlin

val booksPerShelf = 100
val result = db.pipeline()
    .collection("books")
    .select(
        Expression.divide(field("unsoldBooks"), booksPerShelf).ceil().alias("requiredShelves")
    )
    .execute()

Java

int booksPerShelf = 100;
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        Expression.divide(field("unsoldBooks"), booksPerShelf).ceil().alias("requiredShelves")
    )
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

books_per_shelf = 100
result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("unsoldBooks")
        .divide(books_per_shelf)
        .ceil()
        .as_("requiredShelves")
    )
    .execute()
)
Java
int booksPerShelf = 100;
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(ceil(divide(field("unsoldBooks"), booksPerShelf)).as("requiredShelves"))
        .execute()
        .get();

FLOOR

Söz dizimi:

floor[N <: INT32 | INT64 | FLOAT64](number: N) -> N

Açıklama:

number değerinden büyük olmayan en büyük tam sayı değerini döndürür.

Örnekler:

sayı floor(number)
20 20
10 10
0 0
2147483648 2147483648
-0,4 -1,0
0,4 0,0
22,5 22,0
+inf +inf
-inf -inf
Node.js
const result = await db.pipeline()
  .collection("books")
  .addFields(
    field("wordCount").divide(field("pages")).floor().as("wordsPerPage")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .addFields(
    field("wordCount").divide(field("pages")).floor().as("wordsPerPage")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .addFields([
    Field("wordCount").divide(Field("pages")).floor().as("wordsPerPage")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .addFields(
        Expression.divide(field("wordCount"), field("pages")).floor().alias("wordsPerPage")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .addFields(
        Expression.divide(field("wordCount"), field("pages")).floor().alias("wordsPerPage")
    )
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .add_fields(
        Field.of("wordCount").divide(Field.of("pages")).floor().as_("wordsPerPage")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .addFields(floor(divide(field("wordCount"), field("pages"))).as("wordsPerPage"))
        .execute()
        .get();

ROUND

Söz dizimi:

round[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N) -> N
round[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N, places: INT64) -> N

Açıklama:

places sayısını number basamağa yuvarlar. places pozitifse ondalık noktanın sağındaki basamakları, negatifse ondalık noktanın solundaki basamakları yuvarlar.

  • Yalnızca number sağlanırsa en yakın tam değere yuvarlar.
  • Yarımlarda sıfırdan uzaklaştırarak yuvarlar.
  • Negatif places değeriyle yuvarlama taşmaya neden olursa error oluşturulur.

Örnekler:

sayı yerler round(number, places)
15,5 0 16,0
-15,5 0 -16,0
15 1 15
15 0 15
15 -1 20
15 -2 0
15,48924 1 15,5
231-1 -1 [error]
263-1L -1 [error]
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("soldBooks").multiply(field("price")).round().as("partialRevenue"))
  .aggregate(field("partialRevenue").sum().as("totalRevenue"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("soldBooks").multiply(field("price")).round().as("partialRevenue"))
  .aggregate(field("partialRevenue").sum().as("totalRevenue"))
  );
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("soldBooks").multiply(Field("price")).round().as("partialRevenue")])
  .aggregate([Field("partialRevenue").sum().as("totalRevenue")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(Expression.multiply(field("soldBooks"), field("price")).round().alias("partialRevenue"))
    .aggregate(AggregateFunction.sum("partialRevenue").alias("totalRevenue"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(Expression.multiply(field("soldBooks"), field("price")).round().alias("partialRevenue"))
    .aggregate(AggregateFunction.sum("partialRevenue").alias("totalRevenue"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("soldBooks")
        .multiply(Field.of("price"))
        .round()
        .as_("partialRevenue")
    )
    .aggregate(Field.of("partialRevenue").sum().as_("totalRevenue"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(round(multiply(field("soldBooks"), field("price"))).as("partialRevenue"))
        .aggregate(sum("partialRevenue").as("totalRevenue"))
        .execute()
        .get();

TRUNC

Söz dizimi:

trunc[N <: Number](number: N) -> N
trunc[N <: Number](number:  N, places: INT64) -> N

Açıklama:

Bir number sayısını belirtilen sayıda places ondalık basamağa kısaltır. places pozitifse ondalık noktanın sağındaki, negatifse solundaki basamakları keser.

  • Yalnızca number sağlanırsa sıfıra doğru en yakın tam değere kısaltır.
  • Sonuçların kesilmesi taşmaya neden olursa error istisnası oluşturulur.

Örnekler:

sayı yerler trunc(number, places)
15,5 0 %
-15,5 0 -15,0
15 1 15
15 0 15
15 -1 10
15 -2 0
15,48924 1 15,4
-15,48924 2 -15,48

POW

Söz dizimi:

pow(base: FLOAT64, exponent: FLOAT64) -> FLOAT64

Açıklama:

base değerinin exponent üssünü döndürür.

  • base <= 0 ve exponent negatifse hata verir.

  • Herhangi bir exponent için pow(1, exponent) değeri 1'dir.

  • Herhangi bir base için pow(base, 0) değeri 1'dir.

Örnekler:

base üs pow(base, exponent)
2 3 8.0
2 -3 0,125
+inf 0 1.0
1 +inf 1.0
-1 0.5 [error]
0 -1 [error]
Node.js
const googleplex = { latitude: 37.4221, longitude: 122.0853 };
const result = await db.pipeline()
  .collection("cities")
  .addFields(
    field("lat").subtract(constant(googleplex.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("latitudeDifference"),
    field("lng").subtract(constant(googleplex.longitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("longitudeDifference")
  )
  .select(
    field("latitudeDifference").add(field("longitudeDifference")).sqrt()
      // Inaccurate for large distances or close to poles
      .as("approximateDistanceToGoogle")
  )
  .execute();

Web

const googleplex = { latitude: 37.4221, longitude: 122.0853 };
const result = await execute(db.pipeline()
  .collection("cities")
  .addFields(
    field("lat").subtract(constant(googleplex.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("latitudeDifference"),
    field("lng").subtract(constant(googleplex.longitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("longitudeDifference")
  )
  .select(
    field("latitudeDifference").add(field("longitudeDifference")).sqrt()
      // Inaccurate for large distances or close to poles
      .as("approximateDistanceToGoogle")
  )
);
Swift
let googleplex = CLLocation(latitude: 37.4221, longitude: 122.0853)
let result = try await db.pipeline()
  .collection("cities")
  .addFields([
    Field("lat").subtract(Constant(googleplex.coordinate.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("latitudeDifference"),
    Field("lng").subtract(Constant(googleplex.coordinate.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("longitudeDifference")
  ])
  .select([
    Field("latitudeDifference").add(Field("longitudeDifference")).sqrt()
      // Inaccurate for large distances or close to poles
      .as("approximateDistanceToGoogle")
  ])
  .execute()

Kotlin

val googleplex = GeoPoint(37.4221, -122.0853)
val result = db.pipeline()
    .collection("cities")
    .addFields(
        field("lat").subtract(googleplex.latitude)
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("latitudeDifference"),
        field("lng").subtract(googleplex.longitude)
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("longitudeDifference")
    )
    .select(
        field("latitudeDifference").add(field("longitudeDifference")).sqrt()
            // Inaccurate for large distances or close to poles
            .alias("approximateDistanceToGoogle")
    )
    .execute()

Java

GeoPoint googleplex = new GeoPoint(37.4221, -122.0853);
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("cities")
    .addFields(
        field("lat").subtract(googleplex.getLatitude())
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("latitudeDifference"),
        field("lng").subtract(googleplex.getLongitude())
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("longitudeDifference")
    )
    .select(
        field("latitudeDifference").add(field("longitudeDifference")).sqrt()
            // Inaccurate for large distances or close to poles
            .alias("approximateDistanceToGoogle")
    )
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

googleplexLat = 37.4221
googleplexLng = -122.0853
result = (
    client.pipeline()
    .collection("cities")
    .add_fields(
        Field.of("lat")
        .subtract(googleplexLat)
        .multiply(111)  # km per degree
        .pow(2)
        .as_("latitudeDifference"),
        Field.of("lng")
        .subtract(googleplexLng)
        .multiply(111)  # km per degree
        .pow(2)
        .as_("longitudeDifference"),
    )
    .select(
        Field.of("latitudeDifference")
        .add(Field.of("longitudeDifference"))
        .sqrt()
        # Inaccurate for large distances or close to poles
        .as_("approximateDistanceToGoogle")
    )
    .execute()
)
Java
double googleplexLat = 37.4221;
double googleplexLng = -122.0853;
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("cities")
        .addFields(
            pow(multiply(subtract(field("lat"), googleplexLat), 111), 2)
                .as("latitudeDifference"),
            pow(multiply(subtract(field("lng"), googleplexLng), 111), 2)
                .as("longitudeDifference"))
        .select(
            sqrt(add(field("latitudeDifference"), field("longitudeDifference")))
                // Inaccurate for large distances or close to poles
                .as("approximateDistanceToGoogle"))
        .execute()
        .get();

KAREKÖK

Söz dizimi:

sqrt[N <: FLOAT64 | DECIMAL128](number: N) -> N

Açıklama:

number sayısının karekökünü döndürür.

  • number negatifse error oluşturur.

Örnekler:

sayı sqrt(number)
25 5.0
12.002 3,464...
0,0 0,0
NaN NaN
+inf +inf
-inf [error]
x < 0 [error]
Node.js
const googleplex = { latitude: 37.4221, longitude: 122.0853 };
const result = await db.pipeline()
  .collection("cities")
  .addFields(
    field("lat").subtract(constant(googleplex.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("latitudeDifference"),
    field("lng").subtract(constant(googleplex.longitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("longitudeDifference")
  )
  .select(
    field("latitudeDifference").add(field("longitudeDifference")).sqrt()
      // Inaccurate for large distances or close to poles
      .as("approximateDistanceToGoogle")
  )
  .execute();

Web

const googleplex = { latitude: 37.4221, longitude: 122.0853 };
const result = await execute(db.pipeline()
  .collection("cities")
  .addFields(
    field("lat").subtract(constant(googleplex.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("latitudeDifference"),
    field("lng").subtract(constant(googleplex.longitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("longitudeDifference")
  )
  .select(
    field("latitudeDifference").add(field("longitudeDifference")).sqrt()
      // Inaccurate for large distances or close to poles
      .as("approximateDistanceToGoogle")
  )
);
Swift
let googleplex = CLLocation(latitude: 37.4221, longitude: 122.0853)
let result = try await db.pipeline()
  .collection("cities")
  .addFields([
    Field("lat").subtract(Constant(googleplex.coordinate.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("latitudeDifference"),
    Field("lng").subtract(Constant(googleplex.coordinate.latitude))
      .multiply(111 /* km per degree */)
      .pow(2)
      .as("longitudeDifference")
  ])
  .select([
    Field("latitudeDifference").add(Field("longitudeDifference")).sqrt()
      // Inaccurate for large distances or close to poles
      .as("approximateDistanceToGoogle")
  ])
  .execute()

Kotlin

val googleplex = GeoPoint(37.4221, -122.0853)
val result = db.pipeline()
    .collection("cities")
    .addFields(
        field("lat").subtract(googleplex.latitude)
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("latitudeDifference"),
        field("lng").subtract(googleplex.longitude)
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("longitudeDifference")
    )
    .select(
        field("latitudeDifference").add(field("longitudeDifference")).sqrt()
            // Inaccurate for large distances or close to poles
            .alias("approximateDistanceToGoogle")
    )
    .execute()

Java

GeoPoint googleplex = new GeoPoint(37.4221, -122.0853);
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("cities")
    .addFields(
        field("lat").subtract(googleplex.getLatitude())
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("latitudeDifference"),
        field("lng").subtract(googleplex.getLongitude())
            .multiply(111 /* km per degree */)
            .pow(2)
            .alias("longitudeDifference")
    )
    .select(
        field("latitudeDifference").add(field("longitudeDifference")).sqrt()
            // Inaccurate for large distances or close to poles
            .alias("approximateDistanceToGoogle")
    )
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

googleplexLat = 37.4221
googleplexLng = -122.0853
result = (
    client.pipeline()
    .collection("cities")
    .add_fields(
        Field.of("lat")
        .subtract(googleplexLat)
        .multiply(111)  # km per degree
        .pow(2)
        .as_("latitudeDifference"),
        Field.of("lng")
        .subtract(googleplexLng)
        .multiply(111)  # km per degree
        .pow(2)
        .as_("longitudeDifference"),
    )
    .select(
        Field.of("latitudeDifference")
        .add(Field.of("longitudeDifference"))
        .sqrt()
        # Inaccurate for large distances or close to poles
        .as_("approximateDistanceToGoogle")
    )
    .execute()
)
Java
double googleplexLat = 37.4221;
double googleplexLng = -122.0853;
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("cities")
        .addFields(
            pow(multiply(subtract(field("lat"), googleplexLat), 111), 2)
                .as("latitudeDifference"),
            pow(multiply(subtract(field("lng"), googleplexLng), 111), 2)
                .as("longitudeDifference"))
        .select(
            sqrt(add(field("latitudeDifference"), field("longitudeDifference")))
                // Inaccurate for large distances or close to poles
                .as("approximateDistanceToGoogle"))
        .execute()
        .get();

EXP

Söz dizimi:

exp(exponent: FLOAT64) -> FLOAT64

Açıklama:

exponent kuvvetine yükseltilmiş Euler sayısının değerini döndürür. Bu işlev, doğal üstel işlev olarak da adlandırılır.

Örnekler:

üs exp(exponent)
0,0 1.0
10 e^10 (FLOAT64)
+inf +inf
-inf 0
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").exp().as("expRating"))
  .execute();

Web

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

Kotlin

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

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").exp().as_("expRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(exp(field("rating")).as("expRating"))
        .execute()
        .get();

LN

Söz dizimi:

ln(number: FLOAT64) -> FLOAT64

Açıklama:

number sayısının doğal logaritmasını döndürür. Bu işlev, log(number) ile aynıdır.

Örnekler:

sayı ln(number)
1 0,0
2L 0,693...
1.0 0,0
e (FLOAT64) 1.0
-inf NaN
+inf +inf
x <= 0 [error]
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").ln().as("lnRating"))
  .execute();

Web

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

Kotlin

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

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").ln().as_("lnRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(ln(field("rating")).as("lnRating"))
        .execute()
        .get();

LOG

Söz dizimi:

log(number: FLOAT64, base: FLOAT64) -> FLOAT64
log(number: FLOAT64) -> FLOAT64

Açıklama:

number sayısının base tabanındaki logaritmasını döndürür.

  • Yalnızca number sağlanırsa number değerinin base tabanındaki logaritmasını döndürür (ln(number) ile eş anlamlıdır).

Örnekler:

sayı base log(number, base)
100 10 2.0
-inf Numeric NaN
Numeric. +inf NaN
number <= 0 Numeric [error]
Numeric base <= 0 [error]
Numeric 1.0 [error]

LOG10

Söz dizimi:

log10(x: FLOAT64) -> FLOAT64

Açıklama:

number sayısının 10 tabanındaki logaritmasını döndürür.

Örnekler:

sayı log10(number)
100 2.0
-inf NaN
+inf +inf
x <= 0 [error]

RAND

Söz dizimi:

rand() -> FLOAT64

Açıklama:

0.0 (dahil) ile 1.0 (hariç) arasında eşit olarak seçilen sözde rastgele bir kayan nokta sayısı döndürür.

Dizi İşlevleri

Ad Açıklama
ARRAY Her giriş bağımsız değişkeni için bir öğe içeren bir ARRAY döndürür.
ARRAY_CONCAT Birden fazla diziyi tek bir ARRAY içinde birleştirir.
ARRAY_CONTAINS Belirli bir ARRAY, belirli bir değeri içeriyorsa TRUE değerini döndürür.
ARRAY_CONTAINS_ALL Tüm değerler ARRAY içinde mevcutsa TRUE değerini döndürür.
ARRAY_CONTAINS_ANY Değerlerden herhangi biri ARRAY içinde varsa TRUE değerini döndürür.
ARRAY_FILTER Bir ARRAY öğesindeki, bir yüklemi karşılamayan öğeleri filtreler.
ARRAY_FIRST ARRAY içindeki ilk öğeyi döndürür.
ARRAY_FIRST_N ARRAY içindeki ilk n öğeyi döndürür.
ARRAY_GET ARRAY içinde belirtilen dizindeki öğeyi döndürür.
ARRAY_INDEX_OF Bir ARRAY değerinin ilk oluşumunun dizinini döndürür.
ARRAY_INDEX_OF_ALL Bir ARRAY içindeki değerin tüm dizinlerini döndürür.
ARRAY_LENGTH Bir ARRAY içindeki öğe sayısını döndürür.
ARRAY_LAST ARRAY içindeki son öğeyi döndürür.
ARRAY_LAST_N ARRAY içindeki son n öğeyi döndürür.
ARRAY_REVERSE ARRAY içindeki öğelerin sırasını tersine çevirir.
ARRAY_SLICE ARRAY dilimini döndürür.
ARRAY_TRANSFORM İfadeyi her öğeye uygulayarak ARRAY içindeki öğeleri dönüştürür.
MAXIMUM ARRAY içindeki maksimum değeri döndürür.
MAXIMUM_N n içindeki en büyük ARRAY değeri döndürür.
MINIMUM ARRAY içindeki minimum değeri döndürür.
MINIMUM_N n içindeki en küçük ARRAY değeri döndürür.
SUM Bir ARRAY içindeki tüm NUMERIC değerlerinin toplamını döndürür.
JOIN ARRAY içindeki öğelerin birleşimini STRING değeri olarak oluşturur.

ARRAY

Söz dizimi:

array(values: ANY...) -> ARRAY

Açıklama:

Belirtilen öğelerden bir dizi oluşturur.

  • Bir bağımsız değişken yoksa sonuçtaki dizide NULL ile değiştirilir.

Örnekler:

values array(values)
() []
(1, 2, 3) [1, 2, 3]
("a", 1, true) ["a", 1, true]
(1, null) [1, null]
(1, [2, 3]) [1, [2, 3]]

ARRAY_CONCAT

Söz dizimi:

array_concat(arrays: ARRAY...) -> ARRAY

Açıklama:

İki veya daha fazla diziyi tek bir ARRAY içinde birleştirir.

Örnekler:

diziler array_concat(arrays)
([1, 2], [3, 4]) [1, 2, 3, 4]
(["a", "b"], ["c"]) ["a", "b", "c"]
([1], [2], [3]) [1, 2, 3]
([], [1, 2]) [1, 2]
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("genre").arrayConcat([field("subGenre")]).as("allGenres"))
  .execute();
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("genre").arrayConcat([Field("subGenre")]).as("allGenres")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("genre").arrayConcat(field("subGenre")).alias("allGenres"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("genre").array_concat(Field.of("subGenre")).as_("allGenres"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(arrayConcat(field("genre"), field("subGenre")).as("allGenres"))
        .execute()
        .get();

ARRAY_CONTAINS

Söz dizimi:

array_contains(array: ARRAY, value: ANY) -> BOOLEAN

Açıklama:

value, array içinde bulunursa TRUE, aksi takdirde FALSE değerini döndürür.

Örnekler:

dizi value array_contains(array, value)
[1, 2, 3] 2 doğru
[[1, 2], [3]] [1, 2] doğru
[1, null] null doğru
"abc" TÜM FİYATLAR hata
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("genre").arrayContains(constant("mystery")).as("isMystery"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("genre").arrayContains(constant("mystery")).as("isMystery"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("genre").arrayContains(Constant("mystery")).as("isMystery")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("genre").arrayContains("mystery").alias("isMystery"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("genre").array_contains("mystery").as_("isMystery"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(arrayContains(field("genre"), "mystery").as("isMystery"))
        .execute()
        .get();

ARRAY_CONTAINS_ALL

Söz dizimi:

array_contains_all(array: ARRAY, search_values: ARRAY) -> BOOLEAN

Açıklama:

Tüm search_values değerleri array içinde bulunursa TRUE, aksi takdirde FALSE değerini döndürür.

Örnekler:

dizi search_values array_contains_all(array, search_values)
[1, 2, 3] [1, 2] doğru
[1, 2, 3] [1, 4] yanlış
[1, null] [boş] doğru
[NaN] [NaN] doğru
[] [] doğru
[1, 2, 3] [] doğru
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("genre")
      .arrayContainsAll([constant("fantasy"), constant("adventure")])
      .as("isFantasyAdventure")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("genre")
      .arrayContainsAll([constant("fantasy"), constant("adventure")])
      .as("isFantasyAdventure")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("genre")
      .arrayContainsAll([Constant("fantasy"), Constant("adventure")])
      .as("isFantasyAdventure")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("genre")
            .arrayContainsAll(listOf("fantasy", "adventure"))
            .alias("isFantasyAdventure")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("genre")
            .arrayContainsAll(Arrays.asList("fantasy", "adventure"))
            .alias("isFantasyAdventure")
    )
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("genre")
        .array_contains_all(["fantasy", "adventure"])
        .as_("isFantasyAdventure")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            arrayContainsAll(field("genre"), Arrays.asList("fantasy", "adventure"))
                .as("isFantasyAdventure"))
        .execute()
        .get();

ARRAY_CONTAINS_ANY

Söz dizimi:

array_contains_any(array: ARRAY, search_values: ARRAY) -> BOOLEAN

Açıklama:

search_values değerlerinden herhangi biri array içinde bulunursa TRUE, aksi takdirde FALSE değerini döndürür.

Örnekler:

dizi search_values array_contains_any(array, search_values)
[1, 2, 3] [4, 1] doğru
[1, 2, 3] [4, 5] yanlış
[1, 2, null] [boş] doğru
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("genre")
      .arrayContainsAny([constant("fantasy"), constant("nonfiction")])
      .as("isMysteryOrFantasy")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("genre")
      .arrayContainsAny([constant("fantasy"), constant("nonfiction")])
      .as("isMysteryOrFantasy")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("genre")
      .arrayContainsAny([Constant("fantasy"), Constant("nonfiction")])
      .as("isMysteryOrFantasy")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("genre")
            .arrayContainsAny(listOf("fantasy", "nonfiction"))
            .alias("isMysteryOrFantasy")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("genre")
            .arrayContainsAny(Arrays.asList("fantasy", "nonfiction"))
            .alias("isMysteryOrFantasy")
    )
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("genre")
        .array_contains_any(["fantasy", "nonfiction"])
        .as_("isMysteryOrFantasy")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            arrayContainsAny(field("genre"), Arrays.asList("fantasy", "nonfiction"))
                .as("isMysteryOrFantasy"))
        .execute()
        .get();

ARRAY_FILTER

Söz dizimi:

array_filter(array: ARRAY, predicate: (ANY) -> BOOLEAN) -> ARRAY

Açıklama:

array ifadesini kullanarak predicate öğelerini filtreler ve yalnızca koşulu karşılayan öğeleri içeren yeni bir dizi döndürür.

  • array içindeki her öğe için predicate değerlendirilir. true döndürürse öğe sonuca dahil edilir. Aksi takdirde (false veya null döndürürse) öğe atlanır.
  • predicate, boole olmayan veya null olmayan bir değer olarak değerlendirilirse işlev hata döndürür.

Örnekler:

dizi yüklem array_filter(array, predicate)
[1, 2, 3] x -> x > 1 [2, 3]
[1, null, 3] x -> x > 1 [3]
["a", "b", "c"] x -> x != "b" ["a", "c"]
[] x -> true []

ARRAY_GET

Söz dizimi:

array_get(array: ARRAY, index: INT64) -> ANY

Açıklama:

array içinde 0 tabanlı index konumundaki öğeyi döndürür.

  • index negatifse öğelere dizinin sonundan erişilir. Bu durumda -1 son öğedir.
  • array, ARRAY türünde değilse ve null değilse hata döndürür.
  • index sınırların dışındaysa işlev, eksik bir değer döndürür.
  • index, INT64 türünde değilse işlev hata döndürür.

Örnekler:

dizi indeks array_get(array, index)
[1, 2, 3] 0 1
[1, 2, 3] -1 3
[1, 2, 3] 3 yok
[1, 2, 3] -4 yok
"abc" 0 hata
null 0 null
Array "a" hata
Array 2.0 hata

ARRAY_LENGTH

Söz dizimi:

array_length(array: ARRAY) -> INT64

Açıklama:

array içindeki öğe sayısını döndürür.

Örnekler:

dizi array_length(array)
[1, 2, 3] 3
[] 0
[1, 1, 1] 3
[1, null] 2
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("genre").arrayLength().as("genreCount"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("genre").arrayLength().as("genreCount"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("genre").arrayLength().as("genreCount")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("genre").arrayLength().alias("genreCount"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("genre").array_length().as_("genreCount"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(arrayLength(field("genre")).as("genreCount"))
        .execute()
        .get();

ARRAY_REVERSE

Söz dizimi:

array_reverse(array: ARRAY) -> ARRAY

Açıklama:

Belirtilen array değerini tersine çevirir.

Örnekler:

dizi array_reverse(array)
[1, 2, 3] [3, 2, 1]
["a", "b"] ["b", "a"]
[1, 2, 2, 3] [3, 2, 2, 1]
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(arrayReverse(field("genre")).as("reversedGenres"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("genre").arrayReverse().as("reversedGenres"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("genre").arrayReverse().as("reversedGenres")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("genre").arrayReverse().alias("reversedGenres"))
    .execute()
    

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("genre").array_reverse().as_("reversedGenres"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(arrayReverse(field("genre")).as("reversedGenres"))
        .execute()
        .get();

ARRAY_FIRST

Söz dizimi:

array_first(array: ARRAY) -> ANY

Açıklama:

array içindeki ilk öğeyi döndürür. Bu, array_get(array, 0) ile eşdeğerdir.

  • array boşsa eksik bir değer döndürür.

Örnekler:

dizi array_first(array)
[1, 2, 3] 1
[] yok

ARRAY_FIRST_N

Söz dizimi:

array_first_n(array: ARRAY, n: INT64) -> ARRAY

Açıklama:

array öğesinin ilk n öğesini döndürür. Bu, array_slice(array, 0, n) ile eşdeğerdir.

  • n negatifse hata döndürülür.

Örnekler:

dizi n array_first_n(array, n)
[1, 2, 3, 4, 5] 3 [1, 2, 3]
[1, 2] 3 [1, 2]
[1, 2, 3] 0 []

ARRAY_INDEX_OF

Söz dizimi:

array_index_of(array: ARRAY, value: ANY) -> INT64

Açıklama:

value karakterinin array içindeki ilk oluşumunun 0 tabanlı dizinini döndürür. value bulunamazsa -1 değerini döndürür.

Örnekler:

dizi value array_index_of(array, value)
[1, 2, 3, 2] 2 1
[1, 2, 3] 4 -1
[1, null, 3] null 1

ARRAY_INDEX_OF_ALL

Söz dizimi:

array_index_of_all(array: ARRAY, value: ANY) -> ARRAY<INT64>

Açıklama:

value öğesinin array içinde geçtiği tüm yerlerin 0 tabanlı dizinlerini içeren bir dizi döndürür. value bulunamazsa [] değerini döndürür.

Örnekler:

dizi value array_index_of_all(array, value)
[1, 2, 3, 2] 2 [1, 3]
[1, 2, 3] 4 []
[1, null, 3, null] null [1, 3]

ARRAY_LAST

Söz dizimi:

array_last(array: ARRAY) -> ANY

Açıklama:

array içindeki son öğeyi döndürür. Bu, array_get(array, -1) ile eşdeğerdir.

  • array boşsa eksik bir değer döndürür.

Örnekler:

dizi array_last(array)
[1, 2, 3] 3
[] yok

ARRAY_LAST_N

Söz dizimi:

array_last_n(array: ARRAY, n: INT64) -> ARRAY

Açıklama:

array öğesinin son n öğesini döndürür.

  • n negatifse hata döndürülür.

Örnekler:

dizi n array_last_n(array, n)
[1, 2, 3, 4, 5] 3 [3, 4, 5]
[1, 2] 3 [1, 2]
[1, 2, 3] 0 []

ARRAY_SLICE

Söz dizimi:

array_slice(array: ARRAY, offset: INT64, length: INT64) -> ARRAY

Açıklama:

0 tabanlı offset dizininden başlayıp length öğeyi içeren array alt kümesini döndürür.

  • offset negatifse dizinin sonundan itibaren başlangıç konumunu belirtir. -1 son öğedir.
  • length, offset'den sonra dizide kalan öğe sayısından büyükse sonuç dizinin sonuna kadar uzanır.
  • length negatif olmamalıdır. Aksi takdirde hata döndürülür.

Örnekler:

dizi telafi etmek uzunluk array_slice(array, offset, length)
[1, 2, 3, 4, 5] 1 3 [2, 3, 4]
[1, 2, 3, 4, 5] -2 2 [4, 5]
[1, 2, 3] 1 5 [2, 3]
[1, 2, 3] 3 2 []

ARRAY_TRANSFORM

Söz dizimi:

array_transform(array: ARRAY, expression: (ANY) -> ANY) -> ARRAY
array_transform(array: ARRAY, expression: (ANY, INT64) -> ANY) -> ARRAY

Açıklama:

Her öğeye expression işlevini uygulayarak array değerini dönüştürür ve dönüştürülmüş öğeler içeren yeni bir dizi döndürür. Çıkış dizisi her zaman giriş dizisiyle aynı boyutta olur.

  • expression, tekli işlev element -> result veya ikili işlev (element, index) -> result olabilir.
  • expression tekli ise array öğelerinin her biriyle çağrılır.
  • expression ikili ise array öğelerinin her biri ve bunlara karşılık gelen 0 tabanlı dizinle birlikte çağrılır.

Örnekler:

dizi ifade array_transform(array, expression)
[1, 2, 3] x -> x * 2 [2, 4, 6]
[1, 2, 3] x -> x + 1 [2, 3, 4]
[10, 20] (x, i) -> x + i [10, 21]
[] x -> 1 []

MAKSİMUM

Söz dizimi:

maximum(array: ARRAY) -> ANY

Açıklama:

array içindeki maksimum değeri döndürür.

  • NULL değerleri karşılaştırma sırasında yoksayılır.
  • array boşsa veya yalnızca NULL değerlerini içeriyorsa NULL değerini döndürür.

Örnekler:

dizi maximum(array)
[1, 5, 2] 5
[1, null, 5] 5
["a", "c", "b"] "c"
[null, null] null
[] null

MAXIMUM_N

Söz dizimi:

maximum_n(array: ARRAY, n: INT64) -> ARRAY

Açıklama:

n içindeki array en büyük değerlerin dizisini azalan sırada döndürür.

  • NULL değerleri yok sayılır.
  • n negatifse hata döndürülür.

Örnekler:

dizi n maximum_n(array, n)
[1, 5, 2, 4, 3] 3 [5, 4, 3]
[1, null, 5] 3 [5, 1]

MİNİMUM

Söz dizimi:

minimum(array: ARRAY) -> ANY

Açıklama:

array içindeki minimum değeri döndürür.

  • NULL değerleri karşılaştırma sırasında yoksayılır.
  • array boşsa veya yalnızca NULL değerlerini içeriyorsa NULL değerini döndürür.

Örnekler:

dizi minimum(array)
[1, 5, 2] 1
[5, null, 1] 1
["a", "c", "b"] "a"
[null, null] null
[] null

MINIMUM_N

Söz dizimi:

minimum_n(array: ARRAY, n: INT64) -> ARRAY

Açıklama:

n içindeki array en küçük değerlerin dizisini artan sırada döndürür.

  • NULL değerleri yok sayılır.
  • n negatifse hata döndürülür.

Örnekler:

dizi n minimum_n(array, n)
[1, 5, 2, 4, 3] 3 [1, 2, 3]
[5, null, 1] 3 [1, 5]

TOPLA

Söz dizimi:

sum(array: ARRAY) -> INT64 | FLOAT64

Açıklama:

Bir ARRAY içindeki tüm NUMERIC değerlerinin toplamını döndürür.

  • Dizideki sayısal olmayan değerler yoksayılır.
  • Dizideki sayısal değerlerden herhangi biri NaN ise işlev NaN değerini döndürür.
  • Dönüş türü, dizideki en geniş sayısal türe göre belirlenir: INT64 < FLOAT64.
  • Herhangi bir kayan nokta değeri toplanmadan önce 64 bitlik tam sayı taşması meydana gelirse hata döndürülür. Kayan nokta değerleri toplandığında taşma, +/- sonsuzlukla sonuçlanır.
  • Dizide hiç sayısal değer yoksa işlev NULL değerini döndürür.

Örnekler:

dizi sum(array)
[1, 2, 3] 6L
[1L, 2L, 3L] 6L
[2000000000, 2000000000] 4000000000L
[10, 20.5] 30,5
[1, "a", 2] 3L
[INT64.MAX_VALUE, 1] hata
[INT64.MAX_VALUE, 1, -1.0] hata
[INT64.MAX_VALUE, 1.0] 9.223372036854776e+18

KATIL

Söz dizimi:

join[T <: STRING | BYTES](array: ARRAY<T>, delimiter: T) -> STRING
join[T <: STRING | BYTES](array: ARRAY<T>, delimiter: T, null_text: T) -> STRING

Açıklama:

array içindeki öğelerin birleştirilmiş halini STRING olarak döndürür. array, STRING veya BYTES veri türünde olabilir.

  • array, delimiter ve null_text içindeki tüm öğeler aynı türden olmalıdır. Tüm öğeler STRING veya BYTES olmalıdır.
  • null_text sağlanırsa array içindeki tüm NULL değerleri null_text ile değiştirilir.
  • null_text sağlanmazsa array içindeki NULL değerleri sonuçtan çıkarılır.

Örnekler:

null_text sağlanmadığında:

dizi ayırıcı join(array, delimiter)
["a", "b", "c"] "," "a,b,c"
["a", null, "c"] "," "a,c"
[b'a', b'b', b'c'] b',' b'a,b,c'
["a", b'c'] "," hata
["a", "c"] b',' hata
[b'a', b'c'] "," hata

null_text sağlandığında:

dizi ayırıcı null_text join(array, delimiter, null_text)
["a", null, "c"] "," "MISSING" "a,MISSING,c"
[b'a', null, b'c'] b',' b'NULL' b'a,NULL,c'
[null, "b", null] "," "MISSING" "MISSING,b,MISSING"
[b'a', null, null] b',' b'NULL' b'a,NULL,NULL'
["a", null] "," b'N' hata
[b'a', null] b',' "N" hata

Karşılaştırma İşlevleri

Ad Açıklama
EQUAL Eşitlik karşılaştırması
GREATER_THAN Büyüktür karşılaştırması
GREATER_THAN_OR_EQUAL Büyüktür veya eşittir karşılaştırması
LESS_THAN Karşılaştırmadan daha az
LESS_THAN_OR_EQUAL Küçük veya eşit karşılaştırması
NOT_EQUAL Eşit değildir karşılaştırması
CMP Genel karşılaştırma

EŞİT

Söz dizimi:

equal(x: ANY, y: ANY) -> BOOLEAN

Örnekler:

x y equal(x, y)
1L 1L TRUE
1.0 1L TRUE
-1,0 1L FALSE
NaN NaN TRUE
NULL NULL TRUE
NULL ABSENT FALSE

Açıklama:

x ve y eşitse TRUE, aksi takdirde FALSE değerini döndürür.

Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").equal(5).as("hasPerfectRating"))
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("rating").equal(5).alias("hasPerfectRating"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").equal(5).as_("hasPerfectRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(equal(field("rating"), 5).as("hasPerfectRating"))
        .execute()
        .get();

GREATER_THAN

Söz dizimi:

greater_than(x: ANY, y: ANY) -> BOOLEAN

Açıklama:

x değeri y değerinden büyükse TRUE, aksi takdirde FALSE değerini döndürür.

x ve y karşılaştırılabilir değilse FALSE değerini döndürür.

Örnekler:

x y greater_than(x, y)
1L 0,0 TRUE
1L 1L FALSE
1L 2L FALSE
"foo" 0L FALSE
0L "foo" FALSE
NaN 0L FALSE
0L NaN FALSE
NULL NULL FALSE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").greaterThan(4).as("hasHighRating"))
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("rating").greaterThan(4).alias("hasHighRating"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").greater_than(4).as_("hasHighRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(greaterThan(field("rating"), 4).as("hasHighRating"))
        .execute()
        .get();

GREATER_THAN_OR_EQUAL

Söz dizimi:

greater_than_or_equal(x: ANY, y: ANY) -> BOOLEAN

Açıklama:

x değeri y değerine eşit veya daha büyükse TRUE, aksi takdirde FALSE değerini döndürür.

x ve y karşılaştırılabilir değilse FALSE değerini döndürür.

Örnekler:

x y greater_than_or_equal(x, y)
1L 0,0 TRUE
1L 1L TRUE
1L 2L FALSE
"foo" 0L FALSE
0L "foo" FALSE
NaN 0L FALSE
0L NaN FALSE
NULL NULL TRUE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("published").greaterThanOrEqual(1900).alias("publishedIn20thCentury"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("published")
        .greater_than_or_equal(1900)
        .as_("publishedIn20thCentury")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(greaterThanOrEqual(field("published"), 1900).as("publishedIn20thCentury"))
        .execute()
        .get();

LESS_THAN

Söz dizimi:

less_than(x: ANY, y: ANY) -> BOOLEAN

Açıklama:

x, y değerinden küçükse TRUE, aksi takdirde FALSE değerini döndürür.

x ve y karşılaştırılabilir değilse FALSE değerini döndürür.

Örnekler:

x y less_than(x, y)
1L 0,0 FALSE
1L 1L FALSE
1L 2L TRUE
"foo" 0L FALSE
0L "foo" FALSE
NaN 0L FALSE
0L NaN FALSE
NULL NULL FALSE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("published").lessThan(1923).as("isPublicDomainProbably"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("published").lessThan(1923).as("isPublicDomainProbably"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("published").lessThan(1923).as("isPublicDomainProbably")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("published").lessThan(1923).alias("isPublicDomainProbably"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("published").less_than(1923).as_("isPublicDomainProbably"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(lessThan(field("published"), 1923).as("isPublicDomainProbably"))
        .execute()
        .get();

LESS_THAN_OR_EQUAL

Söz dizimi:

less_than_or_equal(x: ANY, y: ANY) -> BOOLEAN

Açıklama:

x, y değerinden küçük veya bu değere eşitse TRUE, aksi takdirde FALSE değerini döndürür.

x ve y karşılaştırılabilir değilse FALSE değerini döndürür.

Örnekler:

x y less_than(x, y)
1L 0,0 FALSE
1L 1L TRUE
1L 2L TRUE
"foo" 0L FALSE
0L "foo" FALSE
NaN 0L FALSE
0L NaN FALSE
NULL NULL TRUE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").lessThanOrEqual(2).as("hasBadRating"))
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("rating").lessThanOrEqual(2).alias("hasBadRating"))
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").less_than_or_equal(2).as_("hasBadRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(lessThanOrEqual(field("rating"), 2).as("hasBadRating"))
        .execute()
        .get();

NOT_EQUAL

Söz dizimi:

not_equal(x: ANY, y: ANY) -> BOOLEAN

Açıklama:

x, y değerine eşit değilse TRUE, eşitse FALSE değerini döndürür.

Örnekler:

x y not_equal(x, y)
1L 1L FALSE
1.0 1L FALSE
-1,0 1L TRUE
NaN 0L TRUE
NaN NaN FALSE
NULL NULL FALSE
NULL ABSENT TRUE
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();

TMM

Söz dizimi:

cmp(x: ANY, y: ANY) -> Int64

Açıklama:

x ile y karşılaştırılır ve şu sonuçlar döndürülür:

  • x, y değerinden büyükse 1L.
  • -1L, x değeri y değerinden küçükse.
  • Aksi takdirde 0L.

Diğer karşılaştırma işlevlerinin aksine, cmp(...) işlevi türler arasında çalışır ve sort(...) aşamasında kullanılan sıralamayı takip eder. Değerlerin türler arasında nasıl sıralandığı hakkında bilgi edinmek için değer türü sırasına bakın.

Örnekler:

x y cmp(x, y)
1L 1L 0L
1.0 1L 0L
-1,0 1L -1L
42.5D "foo" -1L
NULL NULL 0L
NULL ABSENT 0L

Hata Ayıklama İşlevleri

Ad Açıklama
EXISTS Değer eksik bir değer değilse TRUE döndürülür.
IS_ABSENT Değer eksik bir değerse TRUE döndürülür.
IF_ABSENT Değer yoksa ifadeyle değiştirir.
IS_ERROR Temel ifadede hata olup olmadığını yakalar ve kontrol eder.
IF_ERROR Değer hata veriyorsa ifadeyle değiştirir.
ERROR Değerlendirmeyi sonlandırır ve belirtilen mesajla bir hata döndürür.

EXISTS

Söz dizimi:

exists(value: ANY) -> BOOLEAN

Açıklama:

TRUE, eksik değer değilse value değerini döndürür.

Örnekler:

value exists(value)
0L TRUE
"foo" TRUE
NULL TRUE
ABSENT FALSE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").exists().as("hasRating"))
  .execute();

Web

Örnek:

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

Örnek:

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

Java

Örnek:

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()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(exists(field("rating")).as("hasRating"))
        .execute()
        .get();

IS_ABSENT

Söz dizimi:

is_absent(value: ANY) -> BOOLEAN

Açıklama:

TRUE değeri yoksa value, aksi takdirde FALSE değerini döndürür. Eksik değerler, girişten eksik olan değerlerdir (ör. eksik bir belge alanı).

Örnekler:

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

IF_ABSENT

Söz dizimi:

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

Açıklama:

value değeri yoksa replacement değerini değerlendirip döndürür. Aksi takdirde value değerini döndürür.

Örnekler:

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

IS_ERROR

Söz dizimi:

is_error(try: ANY) -> BOOLEAN

Açıklama:

try değerlendirilirken bir hata oluşursa TRUE değerini döndürür. Aksi takdirde FALSE değerini döndürür.

IF_ERROR

Söz dizimi:

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

Açıklama:

try değerlendirilirken bir hata oluşursa replacement değerlendirilir ve döndürülür. Aksi takdirde, try değerinin çözümlenmiş halini döndürür.

HATA

Söz dizimi:

error(message: STRING) -> ANY

Açıklama:

error işlevinin değerlendirilmesi, işlem hattının hata ile sonlandırılmasına neden olur. Belirtilen message, hataya dahil edilmiştir.

Örnekler:

cond res switch_on(cond, res, error("no condition matched"))
TRUE 1L 1L
FALSE 1L ERROR ("no condition matched")

Referans İşlevleri

REFERENCE türü, veritabanındaki (veya diğer veritabanlarındaki) diğer dokümanlara yönelik bir "işaretçi" görevi görür. Aşağıdaki işlevler, sorgu yürütme sırasında bu türü değiştirmenize olanak tanır.

Ad Açıklama
COLLECTION_ID Belirtilen referanstaki yaprak koleksiyonunun kimliğini döndürür.
DOCUMENT_ID Belirtilen referanstaki belgenin kimliğini döndürür.
PARENT Üst referansı döndürür.
REFERENCE_SLICE Belirtilen referanstan segmentlerin bir alt kümesini döndürür.

COLLECTION_ID

Söz dizimi:

collection_id(ref: REFERENCE) -> STRING

Açıklama:

Belirtilen REFERENCE öğesinin alt koleksiyon kimliğini döndürür.

Örnekler:

ref collection_id(ref)
users/user1 "users"
users/user1/posts/post1 "posts"

DOCUMENT_ID

Söz dizimi:

document_id(ref: REFERENCE) -> ANY

Açıklama:

Belirtilen REFERENCE öğesinin doküman kimliğini döndürür.

Örnekler:

ref document_id(ref)
users/user1 "user1"
users/user1/posts/post1 "post1"

PARENT

Söz dizimi:

parent(ref: REFERENCE) -> REFERENCE

Açıklama:

Belirtilen başvurunun üst öğesini REFERENCE veya başvuru zaten kök başvuruyorsa NULL değerini döndürür.

Örnekler:

ref parent(ref)
/ NULL
users/user1 /
users/user1/posts/post1 users/user1

REFERENCE_SLICE

Söz dizimi:

reference_slice(ref: REFERENCE, offset: INT, length: INT) -> REFERENCE

Açıklama:

REFERENCE, (collection_id, document_id) demetlerinin bir listesidir ve bu, array_slice(...) gibi bu listenin görünümünü elde etmenizi sağlar.

Belirtilen ref'nin segmentlerinin bir alt kümesi olan yeni bir REFERENCE döndürür.

  • offset: Dilimin başlangıç dizini (0 tabanlı). Negatifse referansın sonundan itibaren bir uzaklıktır.
  • length: Dilime dahil edilecek segment sayısı.

Örnekler:

ref offset length reference_slice(ref, offset, length)
a/1/b/2/c/3 1L 2L b/2/c/3
a/1/b/2/c/3 0L 2L a/1/b/2
a/1/b/2/c/3 -2L 2L c/3

Mantıksal İşlevler

Ad Açıklama
AND Mantıksal VE işlemi gerçekleştirir.
OR Mantıksal VEYA işlemi gerçekleştirir.
XOR Mantıksal XOR işlemi gerçekleştirir.
NOT Mantıksal DEĞİL işlemi gerçekleştirir.
NOR Mantıksal NOR işlemi gerçekleştirir.
CONDITIONAL Koşullu ifadeye dayalı olarak dalları değerlendirir.
IF_NULL İlk boş olmayan değeri döndürür.
SWITCH_ON Bir dizi koşula göre dalları değerlendirme
EQUAL_ANY Bir değerin dizideki herhangi bir öğeye eşit olup olmadığını kontrol eder.
NOT_EQUAL_ANY Bir değerin dizideki herhangi bir öğeye eşit olup olmadığını kontrol eder.
MAXIMUM Bir değer kümesindeki maksimum değeri döndürür.
MINIMUM Bir değer kümesindeki minimum değeri döndürür.

VE

Söz dizimi:

and(x: BOOLEAN...) -> BOOLEAN

Açıklama:

İki veya daha fazla Boole değerinin mantıksal VE'sini döndürür.

Verilen değerlerden herhangi birinin ABSENT veya NULL olması nedeniyle sonuç elde edilemiyorsa NULL değerini döndürür.

Örnekler:

x y and(x, y)
TRUE TRUE TRUE
FALSE TRUE FALSE
NULL TRUE NULL
ABSENT TRUE NULL
NULL FALSE FALSE
FALSE ABSENT FALSE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    and(field("rating").greaterThan(4), field("price").lessThan(10))
      .as("under10Recommendation")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    and(field("rating").greaterThan(4), field("price").lessThan(10))
      .as("under10Recommendation")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    (Field("rating").greaterThan(4) && Field("price").lessThan(10))
      .as("under10Recommendation")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        Expression.and(field("rating").greaterThan(4),
          field("price").lessThan(10))
            .alias("under10Recommendation")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        Expression.and(
            field("rating").greaterThan(4),
            field("price").lessThan(10)
        ).alias("under10Recommendation")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, And

result = (
    client.pipeline()
    .collection("books")
    .select(
        And(
            Field.of("rating").greater_than(4), Field.of("price").less_than(10)
        ).as_("under10Recommendation")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            and(greaterThan(field("rating"), 4), lessThan(field("price"), 10))
                .as("under10Recommendation"))
        .execute()
        .get();

VEYA

Söz dizimi:

or(x: BOOLEAN...) -> BOOLEAN

Açıklama:

İki veya daha fazla Boole değerinin mantıksal VEYA'sını döndürür.

Verilen değerlerden herhangi birinin ABSENT veya NULL olması nedeniyle sonuç elde edilemiyorsa NULL değerini döndürür.

Örnekler:

x y or(x, y)
TRUE TRUE TRUE
FALSE TRUE TRUE
NULL TRUE TRUE
ABSENT TRUE TRUE
NULL FALSE NULL
FALSE ABSENT NULL
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    or(field("genre").equal("Fantasy"), field("tags").arrayContains("adventure"))
      .as("matchesSearchFilters")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    or(field("genre").equal("Fantasy"), field("tags").arrayContains("adventure"))
      .as("matchesSearchFilters")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    (Field("genre").equal("Fantasy") || Field("tags").arrayContains("adventure"))
      .as("matchesSearchFilters")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        Expression.or(field("genre").equal("Fantasy"),
          field("tags").arrayContains("adventure"))
            .alias("matchesSearchFilters")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        Expression.or(
            field("genre").equal("Fantasy"),
            field("tags").arrayContains("adventure")
        ).alias("matchesSearchFilters")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, And, Or

result = (
    client.pipeline()
    .collection("books")
    .select(
        Or(
            Field.of("genre").equal("Fantasy"),
            Field.of("tags").array_contains("adventure"),
        ).as_("matchesSearchFilters")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            or(equal(field("genre"), "Fantasy"), arrayContains(field("tags"), "adventure"))
                .as("matchesSearchFilters"))
        .execute()
        .get();

XOR

Söz dizimi:

xor(x: BOOLEAN...) -> BOOLEAN

Açıklama:

İki veya daha fazla Boole değerinin mantıksal XOR'unu döndürür.

Belirtilen değerlerden herhangi biri ABSENT veya NULL ise NULL değerini döndürür.

Örnekler:

x y xor(x, y)
TRUE TRUE FALSE
FALSE FALSE FALSE
FALSE TRUE TRUE
NULL TRUE NULL
ABSENT TRUE NULL
NULL FALSE NULL
FALSE ABSENT NULL
Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    xor(field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction"))
      .as("matchesSearchFilters")
  )
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    xor(field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction"))
      .as("matchesSearchFilters")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    (Field("tags").arrayContains("magic") ^ Field("tags").arrayContains("nonfiction"))
      .as("matchesSearchFilters")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        Expression.xor(field("tags").arrayContains("magic"),
          field("tags").arrayContains("nonfiction"))
            .alias("matchesSearchFilters")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        Expression.xor(
            field("tags").arrayContains("magic"),
            field("tags").arrayContains("nonfiction")
        ).alias("matchesSearchFilters")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, Xor

result = (
    client.pipeline()
    .collection("books")
    .select(
        Xor(
            [
                Field.of("tags").array_contains("magic"),
                Field.of("tags").array_contains("nonfiction"),
            ]
        ).as_("matchesSearchFilters")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            xor(
                    arrayContains(field("tags"), "magic"),
                    arrayContains(field("tags"), "nonfiction"))
                .as("matchesSearchFilters"))
        .execute()
        .get();

NOR

Söz dizimi:

nor(x: BOOLEAN...) -> BOOLEAN

Açıklama:

İki veya daha fazla Boole değerinin mantıksal NOR değerini döndürür.

Verilen değerlerden herhangi birinin ABSENT veya NULL olması nedeniyle sonuç elde edilemiyorsa NULL değerini döndürür.

Örnekler:

x y nor(x, y)
TRUE TRUE FALSE
FALSE TRUE FALSE
FALSE FALSE TRUE
NULL TRUE FALSE
ABSENT TRUE FALSE
NULL FALSE NULL
FALSE ABSENT NULL

DEĞİL

Söz dizimi:

not(x: BOOLEAN) -> BOOLEAN

Açıklama:

Bir Boole değerinin mantıksal NOT'unu döndürür.

Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("tags").arrayContains("nonfiction").not()
      .as("isFiction")
  )
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("tags").arrayContains("nonfiction").not()
      .as("isFiction")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    (!Field("tags").arrayContains("nonfiction"))
      .as("isFiction")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        Expression.not(
            field("tags").arrayContains("nonfiction")
        ).alias("isFiction")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        Expression.not(
            field("tags").arrayContains("nonfiction")
        ).alias("isFiction")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, Not

result = (
    client.pipeline()
    .collection("books")
    .select(Not(Field.of("tags").array_contains("nonfiction")).as_("isFiction"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(not(arrayContains(field("tags"), "nonfiction")).as("isFiction"))
        .execute()
        .get();

KOŞULLU

Söz dizimi:

conditional(condition: BOOLEAN, true_case: ANY, false_case: ANY) -> ANY

Açıklama:

true_case değerini değerlendirir ve condition değeri TRUE olarak değerlendirilirse true_case değerini döndürür.

Koşul FALSE, NULL veya ABSENT değeriyle sonuçlanırsa false_case değerini değerlendirip döndürür.

Örnekler:

condition true_case false_case conditional(condition, true_case, false_case)
TRUE 1L 0L 1L
FALSE 1L 0L 0L
NULL 1L 0L 0L
ABSENT 1L 0L 0L
Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("tags").arrayConcat([
      field("pages").greaterThan(100)
        .conditional(constant("longRead"), constant("shortRead"))
    ]).as("extendedTags")
  )
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("tags").arrayConcat([
      field("pages").greaterThan(100)
        .conditional(constant("longRead"), constant("shortRead"))
    ]).as("extendedTags")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("tags").arrayConcat([
      ConditionalExpression(
        Field("pages").greaterThan(100),
        then: Constant("longRead"),
        else: Constant("shortRead")
      )
    ]).as("extendedTags")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("tags").arrayConcat(
            Expression.conditional(
                field("pages").greaterThan(100),
                constant("longRead"),
                constant("shortRead")
            )
        ).alias("extendedTags")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("tags").arrayConcat(
            Expression.conditional(
                field("pages").greaterThan(100),
                constant("longRead"),
                constant("shortRead")
            )
        ).alias("extendedTags")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import (
    Field,
    Constant,
    Conditional,
)

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("tags")
        .array_concat(
            Conditional(
                Field.of("pages").greater_than(100),
                Constant.of("longRead"),
                Constant.of("shortRead"),
            )
        )
        .as_("extendedTags")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            arrayConcat(
                    field("tags"),
                    conditional(
                        greaterThan(field("pages"), 100),
                        constant("longRead"),
                        constant("shortRead")))
                .as("extendedTags"))
        .execute()
        .get();

IF_NULL

Söz dizimi:

if_null(expr: ANY, replacement: ANY) -> ANY

Açıklama:

expr değilse expr değerini döndürür, aksi takdirde replacement değerini değerlendirip döndürür.NULL expr kullanılırsa replacement ifadesi değerlendirilmez.

Örnekler:

expr replacement if_null(expr, replacement)
1L 2L 1L
NULL 2L 2L
ABSENT 2L ABSENT

SWITCH_ON

Söz dizimi:

switch_on(cond1: BOOLEAN, res1: ANY, cond2: BOOLEAN, res2: ANY, ..., [default: ANY]) -> ANY

Açıklama:

Bir dizi koşulu değerlendirir ve ilk TRUE koşulla ilişkili sonucu döndürür. Hiçbir koşul TRUE olarak değerlendirilmezse default değeri sağlanmışsa döndürülür. default değeri sağlanmazsa ve başka hiçbir koşul TRUE olarak değerlendirilmezse hata verilir.

default değeri sağlamak için bunu son bağımsız değişken olarak iletin. Böylece, bağımsız değişkenlerin sayısı tek olur.

Örnekler:

x switch_on(eq(x, 1L), "one", eq(x, 2L), "two", "other")
1L "one" (bir)
2L "two" (iki)
3L "other" (diğer)

EQUAL_ANY

Söz dizimi:

equal_any(value: ANY, search_space: ARRAY) -> BOOLEAN

Açıklama:

value, search_space dizisindeyse TRUE değerini döndürür.

Örnekler:

value search_space equal_any(value, search_space)
0L [1L, 2L, 3L] FALSE
2L [1L, 2L, 3L] TRUE
NULL [1L, 2L, 3L] FALSE
NULL [1L, NULL] TRUE
ABSENT [1L, NULL] FALSE
NaN [1L, NaN, 3L] TRUE
Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("genre").equalAny(["Science Fiction", "Psychological Thriller"])
      .as("matchesGenreFilters")
  )
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("genre").equalAny(["Science Fiction", "Psychological Thriller"])
      .as("matchesGenreFilters")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("genre").equalAny(["Science Fiction", "Psychological Thriller"])
      .as("matchesGenreFilters")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("genre").equalAny(listOf("Science Fiction", "Psychological Thriller"))
            .alias("matchesGenreFilters")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("genre").equalAny(Arrays.asList("Science Fiction", "Psychological Thriller"))
            .alias("matchesGenreFilters")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("genre")
        .equal_any(["Science Fiction", "Psychological Thriller"])
        .as_("matchesGenreFilters")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            equalAny(field("genre"), Arrays.asList("Science Fiction", "Psychological Thriller"))
                .as("matchesGenreFilters"))
        .execute()
        .get();

NOT_EQUAL_ANY

Söz dizimi:

not_equal_any(value: ANY, search_space: ARRAY) -> BOOLEAN

Açıklama:

TRUE, search_space dizisinde yoksa TRUE değerini döndürür.value

Örnekler:

value search_space not_equal_any(value, search_space)
0L [1L, 2L, 3L] TRUE
2L [1L, 2L, 3L] FALSE
NULL [1L, 2L, 3L] TRUE
NULL [1L, NULL] FALSE
ABSENT [1L, NULL] TRUE
NaN [1L, NaN, 3L] FALSE
Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("author").notEqualAny(["George Orwell", "F. Scott Fitzgerald"])
      .as("byExcludedAuthors")
  )
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("author").notEqualAny(["George Orwell", "F. Scott Fitzgerald"])
      .as("byExcludedAuthors")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("author").notEqualAny(["George Orwell", "F. Scott Fitzgerald"])
      .as("byExcludedAuthors")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("author").notEqualAny(listOf("George Orwell", "F. Scott Fitzgerald"))
            .alias("byExcludedAuthors")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("author").notEqualAny(Arrays.asList("George Orwell", "F. Scott Fitzgerald"))
            .alias("byExcludedAuthors")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("author")
        .not_equal_any(["George Orwell", "F. Scott Fitzgerald"])
        .as_("byExcludedAuthors")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(
            notEqualAny(field("author"), Arrays.asList("George Orwell", "F. Scott Fitzgerald"))
                .as("byExcludedAuthors"))
        .execute()
        .get();

MAKSİMUM

Söz dizimi:

maximum(x: ANY...) -> ANY
maximum(x: ARRAY) -> ANY

Açıklama:

Bir değer dizisindeki x maksimum NULL olmayan, ABSENT olmayan değeri döndürür.

NULL ve ABSENT dışındaki değerler yoksa NULL döndürülür.

Birden fazla maksimum eşdeğer değer varsa bu değerlerden herhangi biri döndürülebilir. Değer türü sıralaması, belgelenen sıralamaya göre yapılır.

Örnekler:

x y maximum(x, y)
FALSE TRUE TRUE
FALSE -10L -10L
0,0 -5L 0,0
"foo" "bar" "foo"
"foo" ["foo"] ["foo"]
ABSENT ABSENT NULL
NULL NULL NULL
Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("price").maximum().as("maximumPrice"))
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("price").maximum().as("maximumPrice"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("rating").logicalMaximum([1]).as("flooredRating")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("rating").logicalMaximum(1).alias("flooredRating")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").logical_maximum(1).as_("flooredRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(logicalMaximum(field("rating"), 1).as("flooredRating"))
        .execute()
        .get();

MİNİMUM

Söz dizimi:

minimum(x: ANY...) -> ANY
minimum(x: ARRAY) -> ANY

Açıklama:

Bir değer dizisindeki NULL ve ABSENT dışındaki en küçük değeri döndürür.x

NULL ve ABSENT dışındaki değerler yoksa NULL döndürülür.

Birden fazla minimum eşdeğer değer varsa bu değerlerden herhangi biri döndürülebilir. Değer türü sıralaması, belgelenen sıralamaya göre yapılır.

Örnekler:

x y minimum(x, y)
FALSE TRUE FALSE
FALSE -10L FALSE
0,0 -5L -5L
"foo" "bar" "bar"
"foo" ["foo"] "foo"
ABSENT ABSENT NULL
NULL NULL NULL
Node.js
const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("price").minimum().as("minimumPrice"))
);

Web

const result = await execute(db.pipeline()
  .collection("books")
  .aggregate(field("price").minimum().as("minimumPrice"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("rating").logicalMinimum([5]).as("cappedRating")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("rating").logicalMinimum(5).alias("cappedRating")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").logical_minimum(5).as_("cappedRating"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(logicalMinimum(field("rating"), 5).as("cappedRating"))
        .execute()
        .get();

Harita İşlevleri

Ad Açıklama
MAP Bir dizi anahtar/değer çiftinden bir harita değeri oluşturur.
MAP_GET Belirtilen bir anahtar verildiğinde haritadaki değeri döndürür.
MAP_SET Bir dizi güncellenmiş anahtar içeren haritanın kopyasını döndürür.
MAP_REMOVE Bir dizi anahtarın kaldırıldığı haritanın kopyasını döndürür.
MAP_MERGE Bir dizi haritayı birleştirir.
CURRENT_CONTEXT Geçerli bağlamı harita olarak döndürür.
MAP_KEYS Bir haritadaki tüm anahtarların dizisini döndürür.
MAP_VALUES Bir haritadaki tüm değerlerin dizisini döndürür.
MAP_ENTRIES Bir haritanın anahtar/değer çiftlerinden oluşan bir dizi döndürür.

MAP

Söz dizimi:

map(key: STRING, value: ANY, ...) -> MAP

Açıklama:

Bir dizi anahtar/değer çiftinden harita oluşturur.

MAP_GET

Söz dizimi:

map_get(map: ANY, key: STRING) -> ANY

Açıklama:

Belirtilen bir anahtar verildiğinde haritadaki değeri döndürür. key haritada yoksa veya map bağımsız değişkeni MAP değilse ABSENT değerini döndürür.

Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("awards").mapGet("pulitzer").as("hasPulitzerAward")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("awards").mapGet("pulitzer").as("hasPulitzerAward")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("awards").mapGet("pulitzer").as("hasPulitzerAward")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("awards").mapGet("pulitzer").alias("hasPulitzerAward")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("awards").map_get("pulitzer").as_("hasPulitzerAward"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward"))
        .execute()
        .get();

MAP_SET

Söz dizimi:

map_set(map: MAP, key: STRING, value: ANY, ...) -> MAP

Açıklama:

İçeriği bir dizi anahtar/değer çiftiyle güncellenmiş map değerinin bir kopyasını döndürür.

Belirtilen değer mevcut olmayan bir değere çözümlenirse ilişkili anahtar haritadan kaldırılır.

map bağımsız değişkeni MAP değilse eksik bir değer döndürür.

MAP_REMOVE

Söz dizimi:

map_remove(map: MAP, key: STRING...) -> MAP

Açıklama:

Bir dizi anahtarın kaldırıldığı map değerinin bir kopyasını döndürür.

MAP_MERGE

Söz dizimi:

map_merge(maps: MAP...) -> MAP

2 veya daha fazla haritanın içeriğini birleştirir. Birden fazla haritada çakışan değerler varsa son değer kullanılır.

CURRENT_CONTEXT

Söz dizimi:

current_context() -> MAP

Yürütmenin geçerli noktasındaki tüm kullanılabilir alanlardan oluşan bir harita döndürür.

MAP_KEYS

Söz dizimi:

map_keys(map: MAP) -> ARRAY<STRING>

Açıklama:

map değerinin tüm anahtarlarını içeren bir dizi döndürür.

MAP_VALUES

Söz dizimi:

map_values(map: MAP) -> ARRAY<ANY>

Açıklama:

map değerinin tüm değerlerini içeren bir dizi döndürür.

MAP_ENTRIES

Söz dizimi:

map_entries(map: MAP) -> ARRAY<MAP>

Açıklama:

map değerindeki tüm anahtar/değer çiftlerini içeren bir dizi döndürür.

Her anahtar/değer çifti, k ve v olmak üzere iki girişli bir harita biçiminde olacaktır.

Örnekler:

map map_entries(map)
{} []
{"foo" : 2L} [{"k": "foo", "v" : 2L}]
{"foo" : "bar", "bar" : "foo"} [{"k": "foo", "v" : "bar" }, {"k" : "bar", "v": "foo"}]

Dize İşlevleri

Ad Açıklama
BYTE_LENGTH Bir STRING veya BYTES değerindeki BYTES sayısını döndürür.
CHAR_LENGTH Bir STRING değerindeki Unicode karakter sayısını döndürür.
STARTS_WITH STRING, belirli bir önekle başlıyorsa TRUE değerini döndürür.
ENDS_WITH TRUE, belirli bir sonekle bitiyorsa STRING değerini döndürür.
LIKE STRING, bir kalıpla eşleşiyorsa TRUE değerini döndürür.
REGEX_CONTAINS Bir değer, normal ifadeyle kısmen veya tamamen eşleşiyorsa TRUE döndürür.
REGEX_MATCH Bir değerin herhangi bir kısmı normal ifadeyle eşleşirse TRUE değerini döndürür.
STRING_CONCAT Birden fazla STRING öğesini STRING öğesinde birleştirir.
STRING_CONTAINS Bir değer STRING içeriyorsa TRUE döndürür.
STRING_INDEX_OF STRING veya BYTES değerinin ilk oluşumunun 0 tabanlı dizinini döndürür.
TO_UPPER STRING veya BYTES değerini büyük harfe dönüştürür.
TO_LOWER STRING veya BYTES değerini küçük harfe dönüştürür.
SUBSTRING STRING veya BYTES değerinin alt dizesini alır.
STRING_REVERSE STRING veya BYTES değerini tersine çevirir.
STRING_REPEAT STRING veya BYTES değerini belirtilen sayıda tekrarlar.
STRING_REPLACE_ALL STRING veya BYTES değerinin tüm oluşumlarını değiştirir.
STRING_REPLACE_ONE STRING veya BYTES değerinin ilk oluşumunu değiştirir.
TRIM STRING veya BYTES değerinin başındaki ve sonundaki karakterleri kırpar.
LTRIM STRING veya BYTES değerinin başındaki karakterleri kırpar.
RTRIM STRING veya BYTES değerindeki sondaki karakterleri kırpar.
SPLIT STRING veya BYTES değerini diziye böler.

BYTE_LENGTH

Söz dizimi:

byte_length[T <: STRING | BYTES](value: T) -> INT64

Açıklama:

Bir STRING veya BYTES değerindeki BYTES sayısını döndürür.

Örnekler:

value byte_length(value)
"abc" 3
"xyzabc" 6
b"abc" 3
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("title").byteLength().as("titleByteLength")
  )
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("title").byteLength().alias("titleByteLength")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("title").byte_length().as_("titleByteLength"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(byteLength(field("title")).as("titleByteLength"))
        .execute()
        .get();

CHAR_LENGTH

Söz dizimi:

char_length(value: STRING) -> INT64

Açıklama:

STRING değerindeki Unicode kod noktalarının sayısını döndürür.

Örnekler:

value char_length(value)
"abc" 3
"hello" (merhaba) 5
"world" 5
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("title").charLength().as("titleCharLength")
  )
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("title").charLength().alias("titleCharLength")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("title").char_length().as_("titleCharLength"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(charLength(field("title")).as("titleCharLength"))
        .execute()
        .get();

STARTS_WITH

Söz dizimi:

starts_with(value: STRING, prefix: STRING) -> BOOLEAN

Açıklama:

value, prefix ile başlıyorsa TRUE değerini döndürür.

Örnekler:

value önek starts_with(value, prefix)
"abc" "a" doğru
"abc" "b" yanlış
"abc" "" doğru
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("title").startsWith("The")
      .as("needsSpecialAlphabeticalSort")
  )
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("title").startsWith("The")
            .alias("needsSpecialAlphabeticalSort")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("title").starts_with("The").as_("needsSpecialAlphabeticalSort")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(startsWith(field("title"), "The").as("needsSpecialAlphabeticalSort"))
        .execute()
        .get();

ENDS_WITH

Söz dizimi:

ends_with(value: STRING, postfix: STRING) -> BOOLEAN

Açıklama:

value, postfix ile bitiyorsa TRUE değerini döndürür.

Örnekler:

value son ek ends_with(value, postfix)
"abc" "c" doğru
"abc" "b" yanlış
"abc" "" doğru
Node.js
const result = await db.pipeline()
  .collection("inventory/devices/laptops")
  .select(
    field("name").endsWith("16 inch")
      .as("16InLaptops")
  )
  .execute();
Swift
let result = try await db.pipeline()
  .collection("inventory/devices/laptops")
  .select([
    Field("name").endsWith("16 inch")
      .as("16InLaptops")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("inventory/devices/laptops")
    .select(
        field("name").endsWith("16 inch")
            .alias("16InLaptops")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("inventory/devices/laptops")
    .select(
        field("name").endsWith("16 inch")
            .alias("16InLaptops")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("inventory/devices/laptops")
    .select(Field.of("name").ends_with("16 inch").as_("16InLaptops"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("inventory/devices/laptops")
        .select(endsWith(field("name"), "16 inch").as("16InLaptops"))
        .execute()
        .get();

BEĞENDİM

Söz dizimi:

like(value: STRING, pattern: STRING) -> BOOLEAN

Açıklama:

value, pattern ile eşleşirse TRUE değerini döndürür.

Örnekler:

value desen like(value, pattern)
"Firestore" "Fire%" doğru
"Firestore" "%store" doğru
"Veri deposu" "Data_tore" doğru
"100%" "100\%" doğru
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("genre").like("%Fiction")
      .as("anyFiction")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("genre").like("%Fiction")
      .as("anyFiction")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("genre").like("%Fiction")
      .as("anyFiction")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("genre").like("%Fiction")
            .alias("anyFiction")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("genre").like("%Fiction")
            .alias("anyFiction")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("genre").like("%Fiction").as_("anyFiction"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(like(field("genre"), "%Fiction").as("anyFiction"))
        .execute()
        .get();

REGEX_CONTAINS

Söz dizimi:

regex_contains(value: STRING, pattern: STRING) -> BOOLEAN

Açıklama:

value değerinin bir kısmı pattern ile eşleşirse TRUE değerini döndürür. pattern geçerli bir normal ifade değilse bu işlev error değerini döndürür.

Normal ifadeler, re2 kitaplığının söz dizimine uyar.

Örnekler:

value desen regex_contains(value, pattern)
"Firestore" "Fire" (Ateş) doğru
"Firestore" "store$" doğru
"Firestore" "data" yanlış
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("title").regexContains("Firestore (Enterprise|Standard)")
      .as("isFirestoreRelated")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("title").regexContains("Firestore (Enterprise|Standard)")
      .as("isFirestoreRelated")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("title").regexContains("Firestore (Enterprise|Standard)")
      .as("isFirestoreRelated")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("title").regexContains("Firestore (Enterprise|Standard)")
            .alias("isFirestoreRelated")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("title").regexContains("Firestore (Enterprise|Standard)")
            .alias("isFirestoreRelated")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("title")
        .regex_contains("Firestore (Enterprise|Standard)")
        .as_("isFirestoreRelated")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(
            regexContains(field("title"), "Firestore (Enterprise|Standard)")
                .as("isFirestoreRelated"))
        .execute()
        .get();

REGEX_MATCH

Söz dizimi:

regex_match(value: STRING, pattern: STRING) -> BOOLEAN

Açıklama:

value, pattern ile tamamen eşleşiyorsa TRUE değerini döndürür. pattern geçerli bir normal ifade değilse bu işlev error değerini döndürür.

Normal ifadeler, re2 kitaplığının söz dizimine uyar.

Örnekler:

value desen regex_match(value, pattern)
"Firestore" "F.*store" doğru
"Firestore" "Fire" (Ateş) yanlış
"Firestore" "^F.*e$" doğru
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("title").regexMatch("Firestore (Enterprise|Standard)")
      .as("isFirestoreExactly")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("title").regexMatch("Firestore (Enterprise|Standard)")
      .as("isFirestoreExactly")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("title").regexMatch("Firestore (Enterprise|Standard)")
      .as("isFirestoreExactly")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("title").regexMatch("Firestore (Enterprise|Standard)")
            .alias("isFirestoreExactly")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("title").regexMatch("Firestore (Enterprise|Standard)")
            .alias("isFirestoreExactly")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("title")
        .regex_match("Firestore (Enterprise|Standard)")
        .as_("isFirestoreExactly")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(
            regexMatch(field("title"), "Firestore (Enterprise|Standard)")
                .as("isFirestoreExactly"))
        .execute()
        .get();

STRING_CONCAT

Söz dizimi:

string_concat(values: STRING...) -> STRING

Açıklama:

İki veya daha fazla STRING değerini tek bir sonuçta birleştirir.

Örnekler:

bağımsız değişkenler string_concat(values...)
() hata
("a") "a"
("abc", "def") "abcdef"
("a", "", "c") "ac"
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("title").stringConcat(" by ", field("author"))
      .as("fullyQualifiedTitle")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("title").stringConcat(" by ", field("author"))
      .as("fullyQualifiedTitle")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("title").concat([" by ", Field("author")])
      .as("fullyQualifiedTitle")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("title").concat(" by ", field("author"))
            .alias("fullyQualifiedTitle")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("title").concat(" by ", field("author"))
            .alias("fullyQualifiedTitle")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("title")
        .concat(" by ", Field.of("author"))
        .as_("fullyQualifiedTitle")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(stringConcat(field("title"), " by ", field("author")).as("fullyQualifiedTitle"))
        .execute()
        .get();

STRING_CONTAINS

Söz dizimi:

string_contains(value: STRING, substring: STRING) -> BOOLEAN

Açıklama:

value içinde substring dizesinin olup olmadığını kontrol eder.

Örnekler:

value substring string_contains(value, substring)
"abc" "b" doğru
"abc" "d" yanlış
"abc" "" doğru
"a.c" "." doğru
"☃☃☃" "☃" doğru
Node.js
const result = await db.pipeline()
  .collection("articles")
  .select(
    field("body").stringContains("Firestore")
      .as("isFirestoreRelated")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("articles")
  .select(
    field("body").stringContains("Firestore")
      .as("isFirestoreRelated")
  )
);
Swift
let result = try await db.pipeline()
  .collection("articles")
  .select([
    Field("body").stringContains("Firestore")
      .as("isFirestoreRelated")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("articles")
    .select(
        field("body").stringContains("Firestore")
            .alias("isFirestoreRelated")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("articles")
    .select(
        field("body").stringContains("Firestore")
            .alias("isFirestoreRelated")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("articles")
    .select(Field.of("body").string_contains("Firestore").as_("isFirestoreRelated"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("articles")
        .select(stringContains(field("body"), "Firestore").as("isFirestoreRelated"))
        .execute()
        .get();

STRING_INDEX_OF

Söz dizimi:

string_index_of[T <: STRING | BYTES](value: T, search: T) -> INT64

Açıklama:

search karakterinin value içindeki ilk oluşumunun 0 tabanlı dizinini döndürür.

  • search bulunamazsa -1 değerini döndürür.
  • value bir STRING değeri ise sonuç Unicode kod noktalarıyla ölçülür. BYTES değeri ise bayt cinsinden ölçülür.
  • search, boş bir STRING veya BYTES değeri ise sonuç 0 olur.

Örnekler:

value ara string_index_of(value, search)
"hello world" "o" 4
"hello world" "l" 2
"hello world" "z" -1
"muz" "na" 2
"abc" "" 0
b"abc" b"b" 1
"é" "é" 0
b"é" b"é" 0

TO_UPPER

Söz dizimi:

to_upper[T <: STRING | BYTES](value: T) -> T

Açıklama:

STRING veya BYTES değerini büyük harfe dönüştürür.

Bir bayt veya karakter, UTF-8 küçük harf karakterine karşılık gelmiyorsa değiştirilmeden geçirilir.

Örnekler:

value to_upper(value)
"abc" "ABC"
"AbC" "ABC"
b"abc" b"ABC"
b"a1c" b"A1C"
Node.js
const result = await db.pipeline()
  .collection("authors")
  .select(
    field("name").toUpper()
      .as("uppercaseName")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("authors")
  .select(
    field("name").toUpper()
      .as("uppercaseName")
  )
);
Swift
let result = try await db.pipeline()
  .collection("authors")
  .select([
    Field("name").toUpper()
      .as("uppercaseName")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("authors")
    .select(
        field("name").toUpper()
            .alias("uppercaseName")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("authors")
    .select(
        field("name").toUpper()
            .alias("uppercaseName")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("authors")
    .select(Field.of("name").to_upper().as_("uppercaseName"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("authors")
        .select(toUpper(field("name")).as("uppercaseName"))
        .execute()
        .get();

TO_LOWER

Söz dizimi:

to_lower[T <: STRING | BYTES](value: T) -> T

Açıklama:

STRING veya BYTES değerini küçük harfe dönüştürür.

Bir bayt veya karakter, UTF-8 büyük harf karakterine karşılık gelmiyorsa değiştirilmeden geçirilir.

Örnekler:

value to_lower(value)
"ABC" "abc"
"AbC" "abc"
"A1C" "a1c"
b"ABC" b"abc"
Node.js
const result = await db.pipeline()
  .collection("authors")
  .select(
    field("genre").toLower().equal("fantasy")
      .as("isFantasy")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("authors")
  .select(
    field("genre").toLower().equal("fantasy")
      .as("isFantasy")
  )
);
Swift
let result = try await db.pipeline()
  .collection("authors")
  .select([
    Field("genre").toLower().equal("fantasy")
      .as("isFantasy")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("authors")
    .select(
        field("genre").toLower().equal("fantasy")
            .alias("isFantasy")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("authors")
    .select(
        field("genre").toLower().equal("fantasy")
            .alias("isFantasy")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("authors")
    .select(Field.of("genre").to_lower().equal("fantasy").as_("isFantasy"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("authors")
        .select(equal(toLower(field("genre")), "fantasy").as("isFantasy"))
        .execute()
        .get();

SUBSTRING

Söz dizimi:

substring[T <: STRING | BYTES](input: T, position: INT64) -> T
substring[T <: STRING | BYTES](input: T, position: INT64, length: INT64) -> T

Açıklama:

input dizenin, position (sıfır tabanlı dizin) ile başlayan ve length girişe kadar olan bir alt dizesini döndürür. length sağlanmazsa position ile input'nin sonu arasındaki alt dizeyi döndürür.

  • input bir STRING değeri ise position ve length, Unicode kod noktalarıyla ölçülür. BYTES değeri ise bayt cinsinden ölçülür.

  • position, input uzunluğundan büyükse boş bir alt dize döndürülür. position artı length, input uzunluğundan büyükse alt dize, input'nin sonuna kadar kesilir.

  • position negatifse konum, girişin sonundan alınır. Negatif position değeri girişin boyutundan büyükse konum sıfır olarak ayarlanır. length negatif olmamalıdır.

Örnekler:

length sağlanmadığında:

giriş position substring(input, position)
"abc" 0 "abc"
"abc" 1 "bc"
"abc" 3 ""
"abc" -1 "c"
b"abc" 1 b"bc"

length sağlandığında:

giriş position uzunluk substring(input, position, length)
"abc" 0 1 "a"
"abc" 1 2 "bc"
"abc" -1 1 "c"
b"abc" 0 1 b"a"
Node.js
const result = await db.pipeline()
  .collection("books")
  .where(field("title").startsWith("The "))
  .select(
    field("title").substring(4)
      .as("titleWithoutLeadingThe")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .where(field("title").startsWith("The "))
  .select(
    field("title").substring(4)
      .as("titleWithoutLeadingThe")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .where(Field("title").startsWith("The "))
  .select([
    Field("title").substring(position: 4)
      .as("titleWithoutLeadingThe")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .where(field("title").startsWith("The "))
    .select(
        field("title")
          .substring(constant(4),
            field("title").charLength().subtract(4))
            .alias("titleWithoutLeadingThe")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .where(field("title").startsWith("The "))
    .select(
        field("title").substring(
          constant(4),
            field("title").charLength().subtract(4))
            .alias("titleWithoutLeadingThe")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .where(Field.of("title").starts_with("The "))
    .select(Field.of("title").substring(4).as_("titleWithoutLeadingThe"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .where(startsWith(field("title"), "The "))
        .select(
            substring(field("title"), constant(4), field("title").charLength())
                .as("titleWithoutLeadingThe"))
        .execute()
        .get();

STRING_REVERSE

Söz dizimi:

string_reverse[T <: STRING | BYTES](input: T) -> T

Açıklama:

Sağlanan girişi ters sırada döndürür.

Giriş bir STRING olduğunda karakterler Unicode kod noktalarıyla, giriş bir BYTES değeri olduğunda ise baytlarla sınırlandırılır.

Örnekler:

giriş string_reverse(input)
"abc" "cba"
"a🌹b" "b🌹a"
"hello" (merhaba) "olleh"
b"abc" b"cba"
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("name").reverse().as("reversedName")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("name").reverse().as("reversedName")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("name").reverse().as("reversedName")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("name").reverse().alias("reversedName")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("name").string_reverse().as_("reversedName"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(reverse(field("name")).as("reversedName"))
        .execute()
        .get();

STRING_REPEAT

Söz dizimi:

string_repeat[T <: STRING | BYTES](input: T, repetitions: INT64) -> T

Açıklama:

input değerini repetitions kez tekrarlanmış olarak döndürür.

  • repetitions, negatif olmayan bir tam sayı olmalıdır.
  • repetitions, 0 ise input ile aynı türde boş bir değer döndürür.
  • Sonuç, izin verilen maksimum boyutu (1 MB) aşarsa hata döndürülür.

Örnekler:

giriş tekrarlar string_repeat(input, repetitions)
"foo" 3 "foofoofoo"
"foo" 0 ""
"a " 3 "a a a "
b"ab" 2 b"abab"
"é🦆" 2 "é🦆é🦆"

STRING_REPLACE_ALL

Söz dizimi:

string_replace_all[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T

Açıklama:

input içindeki find ile çakışmayan tüm örnekleri replacement ile değiştirir.

  • Eşleşmeler büyük/küçük harfe duyarlıdır.
  • find boşsa değiştirme işlemi yapılmaz.

Örnekler:

giriş bul değiştirme string_replace_all(input, find, replacement)
"foobarfoo" "foo" "baz" "bazbarbaz"
"ababab" "aba" "c" "cbab"
"foobar" "o" "" "fbar"
"é🦆🌎🦆" "🦆" "a" "éa🌎a"
b"abc" b"b" b"d" b"adc"

STRING_REPLACE_ONE

Söz dizimi:

string_replace_one[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T

Açıklama:

input içinde find öğesinin ilk tekrarını replacement ile değiştirir.

  • Eşleşmeler büyük/küçük harfe duyarlıdır.
  • find boşsa değiştirme işlemi yapılmaz.

Örnekler:

giriş bul değiştirme string_replace_one(input, find, replacement)
"foobarfoo" "foo" "baz" "bazbarfoo"
"é" "é" "a" "a"
b"foobar" b"o" b"z" b"fzoobar"

TRIM

Söz dizimi:

trim[T <: STRING | BYTES](input: T, values_to_trim: T) -> T
trim[T <: STRING | BYTES](input: T) -> T

Açıklama:

Belirtilen bir BYTES veya CHARS grubunu, sağlanan input'nin başından ve sonundan kaldırır.

  • values_to_trim sağlanmazsa boşluk karakterlerini kırpar.

Örnekler:

values_to_trim sağlanmadığında:

giriş trim(input)
" foo " "foo"
b" foo " b"foo"
"foo" "foo"
"" ""
" " ""
"\t foo \n" "foo"
b"\t foo \n" b"foo"
"\r\f\v foo \r\f\v" "foo"
b"\r\f\v foo \r\f\v" b"foo"

values_to_trim sağlandığında:

giriş kırpılacak_değerler trim(input, values_to_trim)
"abcbfooaacb" "abc" "foo"
"abcdaabadbac" "abc" "daabad"
b"C1C2C3" b"C1" b"C2C3"
b"C1C2" "foo" hata
"foo" b"C1" hata

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("name").trim().as("whitespaceTrimmedName")
  )
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("name").trim(" \n\t").as("whitespaceTrimmedName")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("name").trim().alias("whitespaceTrimmedName")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("name").trim().as_("whitespaceTrimmedName"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(trim(field("name")).as("whitespaceTrimmedName"))
        .execute()
        .get();

LTRIM

Söz dizimi:

ltrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
ltrim[T <: STRING | BYTES](value: T) -> T

Açıklama:

Belirtilen bir BYTES veya CHARS kümesini, sağlanan value'nin başından kırpar.

  • to_trim sağlanmazsa baştaki boşluk karakterlerini kırpar.

Örnekler:

to_trim sağlanmadığında:

value ltrim(value)
" foo " "foo "
"foo" "foo"

to_trim sağlandığında:

value to_trim ltrim(value, to_trim)
"aaabc" "a" "bc"
"abacaba" "ba" "caba"
"é" "é" ""

RTRIM

Söz dizimi:

rtrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
rtrim[T <: STRING | BYTES](value: T) -> T

Açıklama:

Belirtilen bir BYTES veya CHARS kümesini, sağlanan value'nin sonundan kırpar.

  • to_trim sağlanmazsa sondaki boşluk karakterlerini kırpar.

Örnekler:

to_trim sağlanmadığında:

value rtrim(value)
" foo " " foo"
"foo" "foo"

to_trim sağlandığında:

value to_trim rtrim(value, to_trim)
"abccc" "c" "ab"
"abacaba" "ba" "abac"
"é" "é" ""

SPLIT

Söz dizimi:

split(input: STRING) -> ARRAY<STRING>
split[T <: STRING | BYTES](input: T, delimiter: T) -> ARRAY<T>

Açıklama:

Bir sınırlayıcı kullanarak STRING veya BYTES değerini böler.

  • STRING için varsayılan ayırıcı virgüldür ,. Ayırıcı, tek bir dize olarak değerlendirilir.

  • BYTES için bir ayırıcı belirtmeniz gerekir.

  • Boş bir sınırlayıcıya göre bölme işlemi, STRING değerleri için bir Unicode kod noktaları dizisi ve BYTES değerleri için bir BYTES dizisi oluşturur.

  • Boş bir STRING öğesini bölmek, tek bir boş STRING içeren bir ARRAY döndürür.

Örnekler:

delimiter sağlanmadığında:

giriş split(input)
"foo,bar,foo" ["foo", "bar", "foo"]
"foo" ["foo"]
",foo," ["", "foo", ""]
"" [""]
b"C120C2C4" hata

delimiter sağlandığında:

giriş ayırıcı split(input, delimiter)
"foo bar foo" " " ["foo", "bar", "foo"]
"foo bar foo" "z" ["foo bar foo"]
"abc" "" ["a", "b", "c"]
b"C1,C2,C4" b"," [b"C1", b"C2", b"C4"]
b"ABC" b"" [b"A", b"B", b"C"]
"foo" b"C1" hata

Zaman Damgası İşlevleri

Ad Açıklama
CURRENT_TIMESTAMP İstek zamanına karşılık gelen bir TIMESTAMP oluşturur.
TIMESTAMP_TRUNC Bir TIMESTAMP değerini belirli bir ayrıntı düzeyine göre kısaltır.
UNIX_MICROS_TO_TIMESTAMP 1970-01-01 00:00:00 UTC tarihinden itibaren geçen mikro saniye sayısını TIMESTAMP biçimine dönüştürür.
UNIX_MILLIS_TO_TIMESTAMP 1970-01-01 00:00:00 UTC tarihinden itibaren geçen milisaniye sayısını TIMESTAMP biçimine dönüştürür.
UNIX_SECONDS_TO_TIMESTAMP 1970-01-01 00:00:00 UTC tarihinden itibaren geçen saniye sayısını TIMESTAMP biçimine dönüştürür.
TIMESTAMP_ADD TIMESTAMP tarihine zaman aralığı ekler.
TIMESTAMP_SUB TIMESTAMP tarihinden bir zaman aralığını çıkarır.
TIMESTAMP_TO_UNIX_MICROS TIMESTAMP değerini, 1970-01-01 00:00:00 UTC tarihinden itibaren geçen mikro saniye sayısına dönüştürür.
TIMESTAMP_TO_UNIX_MILLIS TIMESTAMP değerini, 1970-01-01 00:00:00 UTC tarihinden sonraki milisaniye sayısına dönüştürür.
TIMESTAMP_TO_UNIX_SECONDS TIMESTAMP değerini 1970-01-01 00:00:00 UTC tarihinden itibaren geçen saniye sayısına dönüştürür.
TIMESTAMP_DIFF İki TIMESTAMP arasındaki belirtilen unit aralıklarının tam sayı değerini döndürür.
TIMESTAMP_EXTRACT Bir TIMESTAMP değerinden belirli bir part (ör. yıl, ay, gün) çıkarır.

CURRENT_TIMESTAMP

Söz dizimi:

current_timestamp() -> TIMESTAMP

Açıklama:

İstek zamanının başlangıcındaki zaman damgasını alır input (1970-01-01 00:00:00 UTC tarihinden itibaren mikrosaniye sayısı olarak yorumlanır).

Bu işlev, bir sorgu içinde sabittir ve birden çok kez çağrılırsa her zaman aynı değeri döndürür.

TIMESTAMP_TRUNC

Söz dizimi:

timestamp_trunc(timestamp: TIMESTAMP, granularity: STRING[, timezone: STRING]) -> TIMESTAMP

Açıklama:

Zaman damgasını belirli bir ayrıntı düzeyine göre kısaltır.

granularity bağımsız değişkeni bir dize olmalı ve aşağıdakilerden biri olmalıdır:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day
  • week
  • week([weekday])
  • month
  • quarter
  • year
  • isoyear

timezone bağımsız değişkeni sağlanırsa kesme, belirtilen saat diliminin takvim sınırlarına göre yapılır (ör. gün kesmesi, belirtilen saat diliminde gece yarısına kadar keser). Kısaltma işleminde yaz saati uygulaması dikkate alınır.

timezone belirtilmezse kısaltma işlemi UTC takvim sınırlarına göre yapılır.

timezone bağımsız değişkeni, tz veritabanındaki bir saat diliminin dize gösterimi olmalıdır (ör. America/New_York). GMT değerinden bir fark belirterek özel bir zaman farkı da kullanılabilir.

Örnekler:

timestamp granularity timezone timestamp_trunc(timestamp, granularity, timezone)
2000-01-01 10:20:30:123456 UTC "second" Belirtilmedi 2001-01-01 10:20:30 UTC
1997-05-31 04:30:30 UTC "day" Belirtilmedi 1997-05-31 00:00:00 UTC
1997-05-31 04:30:30 UTC "day" "America/Los_Angeles" 1997-05-30 07:00:00 UTC
2001-03-16 04:00:00 UTC "week(friday) Belirtilmedi 2001-03-16 00:00:00 UTC
2001-03-23 04:00:00 UTC "week(friday) "America/Los_Angeles" 2001-03-23 17:00:00 UTC
2026-01-24 20:00:00 UTC "month" "GMT+06:32:43" 2026-01-01T06:32:43 UTC

UNIX_MICROS_TO_TIMESTAMP

Söz dizimi:

unix_micros_to_timestamp(input: INT64) -> TIMESTAMP

Açıklama:

input değerini (1970-01-01 00:00:00 UTC tarihinden itibaren geçen mikro saniye sayısı olarak yorumlanır) TIMESTAMP değerine dönüştürür. error, input geçerli bir TIMESTAMP'ye dönüştürülemiyorsa hata verir.

Örnekler:

input unix_micros_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
400123456L 1970-01-01 00:06:40.123456 UTC
-1000000L 1969-12-31 23:59:59 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("createdAtMicros")
        .unix_micros_to_timestamp()
        .as_("createdAtString")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(unixMicrosToTimestamp(field("createdAtMicros")).as("createdAtString"))
        .execute()
        .get();

UNIX_MILLIS_TO_TIMESTAMP

Söz dizimi:

unix_millis_to_timestamp(input: INT64) -> TIMESTAMP

Açıklama:

input değerini (1970-01-01 00:00:00 UTC tarihinden itibaren geçen milisaniye sayısı olarak yorumlanır) TIMESTAMP değerine dönüştürür. error, input geçerli bir TIMESTAMP'ye dönüştürülemiyorsa hata verir.

Örnekler:

input unix_millis_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
4000123L 1970-01-01 01:06:40.123 UTC
-1000000L 1969-12-31 23:43:20 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMillis").unixMillisToTimestamp().as("createdAtString")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMillis").unixMillisToTimestamp().as("createdAtString")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAtMillis").unixMillisToTimestamp().as("createdAtString")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("createdAtMillis")
        .unix_millis_to_timestamp()
        .as_("createdAtString")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(unixMillisToTimestamp(field("createdAtMillis")).as("createdAtString"))
        .execute()
        .get();

UNIX_SECONDS_TO_TIMESTAMP

Söz dizimi:

unix_seconds_to_timestamp(input: INT64) -> TIMESTAMP

Açıklama:

input değerini (1970-01-01 00:00:00 UTC tarihinden itibaren geçen saniye sayısı olarak yorumlanır) TIMESTAMP değerine dönüştürür. error, input geçerli bir TIMESTAMP'ye dönüştürülemiyorsa hata verir.

Örnekler:

input unix_seconds_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
60L 1970-01-01 00:01:00 UTC
-300L 1969-12-31 23:55:00 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("createdAtSeconds")
        .unix_seconds_to_timestamp()
        .as_("createdAtString")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(unixSecondsToTimestamp(field("createdAtSeconds")).as("createdAtString"))
        .execute()
        .get();

TIMESTAMP_ADD

Söz dizimi:

timestamp_add(timestamp: TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP

Açıklama:

timestamp hizmetinden unit amount ekler. amount bağımsız değişkeni negatif olabilir. Bu durumda TIMESTAMP_SUB ile eşdeğerdir.

unit bağımsız değişkeni bir dize olmalı ve aşağıdakilerden biri olmalıdır:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day

Sonuçta elde edilen zaman damgası TIMESTAMP aralığına uymuyorsa hata verir.

Örnekler:

timestamp unit amount timestamp_add(timestamp, unit, amount)
2025-02-20 00:00:00 UTC "dakika" 2L 2025-02-20 00:02:00 UTC
2025-02-20 00:00:00 UTC "hour" -4L 2025-02-19 20:00:00 UTC
2025-02-20 00:00:00 UTC "day" 5L 2025-02-25 00:00:00 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAt").timestampAdd("day", 3653).as("expiresAt")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAt").timestampAdd("day", 3653).as("expiresAt")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAt").timestampAdd(3653, .day).as("expiresAt")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAt")
          .timestampAdd("day", 3653)
          .alias("expiresAt")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAt").timestampAdd("day", 3653).alias("expiresAt")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("createdAt").timestamp_add("day", 3653).as_("expiresAt"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampAdd(field("createdAt"), "day", 3653).as("expiresAt"))
        .execute()
        .get();

TIMESTAMP_SUB

Söz dizimi:

timestamp_sub(timestamp: TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP

Açıklama:

amount, timestamp değerinden unit çıkarılır. amount bağımsız değişkeni negatif olabilir. Bu durumda TIMESTAMP_ADD ile eşdeğerdir.

unit bağımsız değişkeni bir dize olmalı ve aşağıdakilerden biri olmalıdır:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day

Sonuçta elde edilen zaman damgası TIMESTAMP aralığına uymuyorsa hata verir.

Örnekler:

timestamp unit amount timestamp_sub(timestamp, unit, amount)
2026-07-04 00:00:00 UTC "dakika" 40L 2026-07-03 23:20:00 UTC
2026-07-04 00:00:00 UTC "hour" -24L 2026-07-05 00:00:00 UTC
2026-07-04 00:00:00 UTC "day" 3L 2026-07-01 00:00:00 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("expiresAt").timestampSubtract(14, .day).as("sendWarningTimestamp")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("expiresAt")
          .timestampSubtract("day", 14)
          .alias("sendWarningTimestamp")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("expiresAt").timestampSubtract("day", 14).alias("sendWarningTimestamp")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("expiresAt")
        .timestamp_subtract("day", 14)
        .as_("sendWarningTimestamp")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampSubtract(field("expiresAt"), "day", 14).as("sendWarningTimestamp"))
        .execute()
        .get();

TIMESTAMP_TO_UNIX_MICROS

Söz dizimi:

timestamp_to_unix_micros(input: TIMESTAMP) -> INT64

Açıklama:

input değerini, 1970-01-01 00:00:00 UTC tarihinden itibaren geçen mikro saniye sayısına dönüştürür. Mikrosaniyenin başına yuvarlayarak daha yüksek hassasiyet düzeylerini keser.

Örnekler:

input timestamp_to_unix_micros(input)
1970-01-01 00:00:00 UTC 0L
1970-01-01 00:06:40.123456 UTC 400123456L
1969-12-31 23:59:59 UTC -1000000L
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMicros().as("unixMicros")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMicros().as("unixMicros")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("dateString").timestampToUnixMicros().as("unixMicros")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMicros().alias("unixMicros")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMicros().alias("unixMicros")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("dateString").timestamp_to_unix_micros().as_("unixMicros"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampToUnixMicros(field("dateString")).as("unixMicros"))
        .execute()
        .get();

TIMESTAMP_TO_UNIX_MILLIS

Söz dizimi:

timestamp_to_unix_millis(input: TIMESTAMP) -> INT64

Açıklama:

input değerini, 1970-01-01 00:00:00 UTC tarihinden itibaren geçen milisaniye sayısına dönüştürür. Milisaniyenin başına yuvarlayarak daha yüksek hassasiyet seviyelerini keser.

Örnekler:

input timestamp_to_unix_millis(input)
1970-01-01 00:00:00 UTC 0L
1970-01-01 01:06:40.123 UTC 4000123L
1969-12-31 23:43:20 -1000000L
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMillis().as("unixMillis")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMillis().as("unixMillis")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("dateString").timestampToUnixMillis().as("unixMillis")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMillis().alias("unixMillis")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMillis().alias("unixMillis")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("dateString").timestamp_to_unix_millis().as_("unixMillis"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampToUnixMillis(field("dateString")).as("unixMillis"))
        .execute()
        .get();

TIMESTAMP_TO_UNIX_SECONDS

Söz dizimi:

timestamp_to_unix_seconds(input: TIMESTAMP) -> INT64

Açıklama:

input değerini 1970-01-01 00:00:00 UTC tarihinden itibaren geçen saniye sayısına dönüştürür. Saniyelerin başına yuvarlayarak daha yüksek hassasiyet düzeylerini kısaltır.

Örnekler:

input timestamp_to_unix_seconds(input)
1970-01-01 00:00:00 UTC 0L
1970-01-01 00:01:00 UTC 60L
1969-12-31 23:55:00 UTC -300L
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixSeconds().as("unixSeconds")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixSeconds().as("unixSeconds")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("dateString").timestampToUnixSeconds().as("unixSeconds")
  ])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixSeconds().alias("unixSeconds")
    )
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixSeconds().alias("unixSeconds")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("dateString").timestamp_to_unix_seconds().as_("unixSeconds"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampToUnixSeconds(field("dateString")).as("unixSeconds"))
        .execute()
        .get();

TIMESTAMP_DIFF

Söz dizimi:

timestamp_diff(end: TIMESTAMP, start: TIMESTAMP, unit: STRING) -> INT64

Açıklama:

İki TIMESTAMP arasındaki belirtilen unit aralıklarının tam sayı değerini döndürür.

  • end, start tarihinden önceyse negatif bir değer döndürür.
  • Tüm kesirli birimleri kısaltır. Örneğin, timestamp_diff("2021-01-01 00:00:01", "2021-01-01 00:00:00", "minute"), 0 değerini döndürür.

unit bağımsız değişkeni bir dize olmalı ve aşağıdakilerden biri olmalıdır:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day

Örnekler:

end start unit timestamp_diff(end, start, unit)
2026-07-04 00:01:00 UTC 2026-07-04 00:00:00 UTC "second" 60L
2026-07-04 00:00:00 UTC 2026-07-05 00:00:00 UTC "day" -1L
2026-07-04 00:00:59 UTC 2026-07-04 00:00:00 UTC "dakika" 0L

TIMESTAMP_EXTRACT

Söz dizimi:

timestamp_extract(timestamp: TIMESTAMP, part: STRING[, timezone: STRING]) -> INT64

Açıklama:

timestamp tarihinden belirli bir part (ör. yıl, ay, gün) çıkarır.

part bağımsız değişkeni bir dize olmalı ve aşağıdakilerden biri olmalıdır:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day
  • dayofweek: 1 (Pazar) ile 7 (Cumartesi) arasında bir değer döndürür.
  • dayofyear
  • week: Yılın ilk pazar gününden başlayarak yılın hafta numarasını döndürür.
  • week([weekday]): Belirtilen weekday ile başlayan yılın hafta numarasını döndürür.
  • month
  • quarter
  • year
  • isoweek: ISO 8601 hafta numarasını döndürür.
  • isoyear: ISO 8601 hafta numaralandırma yılını döndürür.

timezone bağımsız değişkeni sağlanırsa ayıklama, verilen saat diliminin takvimine göre yapılır. Ayıklama işleminde yaz saati uygulaması dikkate alınır.

timezone sağlanmazsa ayıklama UTC temel alınarak yapılır.

timezone bağımsız değişkeni, saat dilimi veritabanındaki bir saat diliminin dize gösterimi olmalıdır. Örneğin, America/New_York. GMT değerinden fark belirterek özel bir zaman farkı da kullanılabilir.

Örnekler:

timestamp part timezone timestamp_extract(timestamp, part, timezone)
2025-02-20 10:20:30 UTC "year" Belirtilmedi 2025
2025-02-20 10:20:30 UTC "day" Belirtilmedi 20
2025-12-31 23:59:59 UTC "year" "Asia/Tokyo" 2026

Tür İşlevleri

Ad Açıklama
TYPE Değerin türünü STRING olarak döndürür.
IS_TYPE Değer belirtilen türle eşleşiyorsa true değerini döndürür.

TÜR

Söz dizimi:

type(input: ANY) -> STRING

Açıklama:

input türünün dize gösterimini döndürür.

Değer verilmezse NULL döndürülür.

Örnekler:

input type(input)
NULL "null"
doğru "boolean"
1 "int32"
-3L "int64"
3.14 "float64"
2024-01-01T00:00:00Z UTC "timestamp"
"foo" "string"
b"foo" "bytes"
[1, 2] "array"
{"a": 1} "map"
path("c/d") "reference"
vector([1.0, 2.0]) "vector"
ABSENT NULL

Müşteri örnekleri

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

Söz dizimi:

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

Açıklama:

input, belirtilen type ile eşleşirse true, aksi takdirde false değerini döndürür. input değeri yoksa NULL döndürülür.

Desteklenen type dizeleri:

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

Örnekler:

input type is_type(input, type)
NULL "null" doğru
doğru "boolean" doğru
3.14 "float64" doğru
"foo" "string" doğru
b"foo" "string" yanlış
[1, 2] "array" doğru
{"a": 1} "map" doğru
vector([1.0, 2.0]) "vektör" doğru
ABSENT "string" NULL
"bar" "other" (diğer) HATA

Vektör İşlevleri

Ad Açıklama
COSINE_DISTANCE İki vektör arasındaki kosinüs uzaklığını döndürür.
DOT_PRODUCT İki vektör arasındaki iç çarpımı döndürür.
EUCLIDEAN_DISTANCE İki vektör arasındaki Öklid uzaklığını döndürür.
MANHATTAN_DISTANCE İki vektör arasındaki Manhattan mesafesini döndürür.
VECTOR_LENGTH Bir vektördeki öğe sayısını döndürür.

COSINE_DISTANCE

Söz dizimi:

cosine_distance(x: VECTOR, y: VECTOR) -> FLOAT64

Açıklama:

x ile y arasındaki kosinüs uzaklığını döndürür.

Node.js
const sampleVector = [0.0, 1, 2, 3, 4, 5];
const result = await db.pipeline()
  .collection("books")
  .select(
    field("embedding").cosineDistance(sampleVector).as("cosineDistance")
  )
  .execute();

Web

const sampleVector = [0.0, 1, 2, 3, 4, 5];
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("embedding").cosineDistance(sampleVector).as("cosineDistance")));
Swift
let sampleVector = [0.0, 1, 2, 3, 4, 5]
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("embedding").cosineDistance(sampleVector).as("cosineDistance")
  ])
  .execute()

Kotlin

val sampleVector = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0)
val result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").cosineDistance(sampleVector).alias("cosineDistance")
    )
    .execute()

Java

double[] sampleVector = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").cosineDistance(sampleVector).alias("cosineDistance")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field
from google.cloud.firestore_v1.vector import Vector

sample_vector = Vector([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("embedding").cosine_distance(sample_vector).as_("cosineDistance")
    )
    .execute()
)
Java
double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(cosineDistance(field("embedding"), sampleVector).as("cosineDistance"))
        .execute()
        .get();

DOT_PRODUCT

Söz dizimi:

dot_product(x: VECTOR, y: VECTOR) -> FLOAT64

Açıklama:

x ve y'nin nokta çarpımını döndürür.

Node.js
const sampleVector = [0.0, 1, 2, 3, 4, 5];
const result = await db.pipeline()
  .collection("books")
  .select(
    field("embedding").dotProduct(sampleVector).as("dotProduct")
  )
  .execute();

Web

const sampleVector = [0.0, 1, 2, 3, 4, 5];
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("embedding").dotProduct(sampleVector).as("dotProduct")
  )
);
Swift
let sampleVector = [0.0, 1, 2, 3, 4, 5]
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("embedding").dotProduct(sampleVector).as("dotProduct")
  ])
  .execute()

Kotlin

val sampleVector = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0)
val result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").dotProduct(sampleVector).alias("dotProduct")
    )
    .execute()

Java

double[] sampleVector = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").dotProduct(sampleVector).alias("dotProduct")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field
from google.cloud.firestore_v1.vector import Vector

sample_vector = Vector([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("embedding").dot_product(sample_vector).as_("dotProduct"))
    .execute()
)
Java
double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(dotProduct(field("embedding"), sampleVector).as("dotProduct"))
        .execute()
        .get();

EUCLIDEAN_DISTANCE

Söz dizimi:

euclidean_distance(x: VECTOR, y: VECTOR) -> FLOAT64

Açıklama:

x ile y arasındaki Öklid uzaklığını hesaplar.

Node.js
const sampleVector = [0.0, 1, 2, 3, 4, 5];
const result = await db.pipeline()
  .collection("books")
  .select(
    field("embedding").euclideanDistance(sampleVector).as("euclideanDistance")
  )
  .execute();

Web

const sampleVector = [0.0, 1, 2, 3, 4, 5];
const result = await execute(db.pipeline()
  .collection("books")
  .select(
    field("embedding").euclideanDistance(sampleVector).as("euclideanDistance")
  )
);
Swift
let sampleVector = [0.0, 1, 2, 3, 4, 5]
let result = try await db.pipeline()
  .collection("books")
  .select([
    Field("embedding").euclideanDistance(sampleVector).as("euclideanDistance")
  ])
  .execute()

Kotlin

val sampleVector = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0)
val result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").euclideanDistance(sampleVector).alias("euclideanDistance")
    )
    .execute()

Java

double[] sampleVector = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").euclideanDistance(sampleVector).alias("euclideanDistance")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field
from google.cloud.firestore_v1.vector import Vector

sample_vector = Vector([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("embedding")
        .euclidean_distance(sample_vector)
        .as_("euclideanDistance")
    )
    .execute()
)
Java
double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(euclideanDistance(field("embedding"), sampleVector).as("euclideanDistance"))
        .execute()
        .get();

MANHATTAN_DISTANCE

Söz dizimi:

manhattan_distance(x: VECTOR, y: VECTOR) -> FLOAT64

Açıklama:

x ile y arasındaki Manhattan uzaklığını hesaplar.

VECTOR_LENGTH

Söz dizimi:

vector_length(vector: VECTOR) -> INT64

Açıklama:

Bir VECTOR içindeki öğe sayısını döndürür.

Node.js
const result = await db.pipeline()
  .collection("books")
  .select(
    field("embedding").vectorLength().as("vectorLength")
  )
  .execute();

Web

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

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(
        field("embedding").vectorLength().alias("vectorLength")
    )
    .execute()

Java

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

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("embedding").vector_length().as_("vectorLength"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(vectorLength(field("embedding")).as("vectorLength"))
        .execute()
        .get();