Dize işlevleri

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 TRUE, belirli bir önekle başlıyorsa STRING 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 geçtiği yerin 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