دوال السلسلة
| الاسم | الوصف |
BYTE_LENGTH
|
تعرِض عدد BYTES في قيمة STRING أو BYTES
|
CHAR_LENGTH
|
تعرض هذه الدالة عدد أحرف Unicode في قيمة STRING
|
STARTS_WITH
|
عرض TRUE إذا كان STRING يبدأ ببادئة معيّنة
|
ENDS_WITH
|
تعرِض TRUE إذا انتهى STRING بلاحقة معيّنة
|
LIKE
|
تعرض TRUE إذا كان STRING يطابق نمطًا
|
REGEX_CONTAINS
|
تعرض الدالة TRUE إذا كانت القيمة تطابق تعبيرًا عاديًا بشكل جزئي أو كامل
|
REGEX_MATCH
|
تعرض الدالة TRUE إذا كان أي جزء من القيمة يتطابق مع تعبير عادي
|
STRING_CONCAT
|
يجمع بين عدة STRING في STRING
|
STRING_CONTAINS
|
تعرض TRUE إذا كانت القيمة تحتوي على STRING
|
STRING_INDEX_OF
|
تعرض هذه الدالة الفهرس المستند إلى الرقم 0 لأول ظهور للقيمة STRING أو BYTES.
|
TO_UPPER
|
تحويل قيمة STRING أو BYTES إلى أحرف كبيرة
|
TO_LOWER
|
تحويل قيمة STRING أو BYTES إلى أحرف صغيرة
|
SUBSTRING
|
تعرض هذه الدالة سلسلة فرعية من قيمة STRING أو BYTES.
|
STRING_REVERSE
|
تعكس هذه الدالة قيمة STRING أو BYTES.
|
STRING_REPEAT
|
تكرّر قيمة STRING أو BYTES عددًا محددًا من المرات.
|
STRING_REPLACE_ALL
|
يستبدل كل تكرارات القيمة STRING أو BYTES.
|
STRING_REPLACE_ONE
|
يستبدل أول ظهور للقيمة STRING أو BYTES.
|
TRIM
|
تقص الأحرف البادئة واللاحقة من قيمة STRING أو BYTES.
|
LTRIM
|
تزيل هذه الدالة الأحرف الأولى من قيمة STRING أو BYTES.
|
RTRIM
|
تزيل هذه الدالة الأحرف الأخيرة من قيمة STRING أو BYTES.
|
SPLIT
|
تقسّم قيمة STRING أو BYTES إلى صفيف.
|
BYTE_LENGTH
البنية:
byte_length[T <: STRING | BYTES](value: T) -> INT64
الوصف:
تعرض هذه الدالة عدد BYTES في قيمة STRING أو BYTES.
أمثلة:
| القيمة | 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
البنية:
char_length(value: STRING) -> INT64
الوصف:
تعرض هذه الدالة عدد نقاط رموز Unicode في قيمة STRING.
أمثلة:
| القيمة | char_length(value) |
|---|---|
| "abc" | 3 |
| "hello" | 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
البنية:
starts_with(value: STRING, prefix: STRING) -> BOOLEAN
الوصف:
تعرِض الدالة القيمة TRUE إذا كانت السلسلة value تبدأ بالسلسلة prefix.
أمثلة:
| القيمة | بادئة | starts_with(value, prefix) |
|---|---|---|
| "abc" | "a" | صحيح |
| "abc" | "b" | خطأ |
| "abc" | "" | صحيح |
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
البنية:
ends_with(value: STRING, postfix: STRING) -> BOOLEAN
الوصف:
تعرِض TRUE إذا كانت value تنتهي بـ postfix.
أمثلة:
| القيمة | لاحقة | ends_with(value, postfix) |
|---|---|---|
| "abc" | "c" | صحيح |
| "abc" | "b" | خطأ |
| "abc" | "" | صحيح |
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();
أعجبني
البنية:
like(value: STRING, pattern: STRING) -> BOOLEAN
الوصف:
تعرض TRUE إذا كان value مطابقًا pattern.
أمثلة:
| القيمة | نموذج | like(value, pattern) |
|---|---|---|
| "Firestore" | "Fire%" | صحيح |
| "Firestore" | %store | صحيح |
| "Datastore" | "Data_tore" | صحيح |
| "100%" | "100\%" | صحيح |
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
البنية:
regex_contains(value: STRING, pattern: STRING) -> BOOLEAN
الوصف:
تعرض هذه الدالة TRUE إذا كان جزء من value يتطابق مع pattern. إذا لم يكن pattern تعبيرًا عاديًا صالحًا، ستعرض هذه الدالة error.
تتّبع التعبيرات العادية بنية مكتبة re2.
أمثلة:
| القيمة | نموذج | regex_contains(value, pattern) |
|---|---|---|
| "Firestore" | "نار" | صحيح |
| "Firestore" | "store$" | صحيح |
| "Firestore" | "data" | خطأ |
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
البنية:
regex_match(value: STRING, pattern: STRING) -> BOOLEAN
الوصف:
تعرض هذه الدالة TRUE إذا كانت value تطابق pattern تمامًا. إذا لم يكن pattern تعبيرًا عاديًا صالحًا، ستعرض هذه الدالة error.
تتّبع التعبيرات العادية بنية مكتبة re2.
أمثلة:
| القيمة | نموذج | regex_match(value, pattern) |
|---|---|---|
| "Firestore" | "F.*store" | صحيح |
| "Firestore" | "نار" | خطأ |
| "Firestore" | "^F.*e$" | صحيح |
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
البنية:
string_concat(values: STRING...) -> STRING
الوصف:
تدمج هذه الدالة قيمتَين أو أكثر من النوع STRING في نتيجة واحدة.
أمثلة:
| الوسيطات | string_concat(values...) |
|---|---|
() |
خطأ |
("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
البنية:
string_contains(value: STRING, substring: STRING) -> BOOLEAN
الوصف:
تتحقّق هذه الدالة ممّا إذا كانت value تحتوي على السلسلة الحرفية substring.
أمثلة:
| القيمة | سلسلة فرعية | string_contains(value, substring) |
|---|---|---|
| "abc" | "b" | صحيح |
| "abc" | "d" | خطأ |
| "abc" | "" | صحيح |
| "a.c" | "." | صحيح |
| "☃☃☃" | "☃" | صحيح |
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
البنية:
string_index_of[T <: STRING | BYTES](value: T, search: T) -> INT64
الوصف:
تعرِض هذه الدالة الفهرس المستند إلى الرقم 0 لأول تكرار لـ search في value.
- تعرض الدالة القيمة
-1إذا لم يتم العثور علىsearch. - إذا كانت
valueقيمةSTRING، يتم قياس النتيجة بنقاط رموز Unicode. إذا كانت قيمةBYTES، يتم قياسها بالبايت. - إذا كانت
searchقيمةSTRINGأوBYTESفارغة، تكون النتيجة0.
أمثلة:
| القيمة | عملية بحث واحدة | string_index_of(value, search) |
|---|---|---|
| "hello world" | "o" | 4 |
| "hello world" | "l" | 2 |
| "hello world" | "z" | -1 |
| "موزة" | "na" | 2 |
| "abc" | "" | 0 |
| b"abc" | b"b" | 1 |
| "é" | "é" | 0 |
| b"é" | b"é" | 0 |
TO_UPPER
البنية:
to_upper[T <: STRING | BYTES](value: T) -> T
الوصف:
تحويل قيمة STRING أو BYTES إلى أحرف كبيرة
إذا لم يكن البايت أو الحرف مطابقًا لحرف أبجدي صغير في UTF-8، يتم تمريره بدون تغيير.
أمثلة:
| القيمة | 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
البنية:
to_lower[T <: STRING | BYTES](value: T) -> T
الوصف:
تحويل قيمة STRING أو BYTES إلى أحرف صغيرة
إذا لم يكن البايت أو الحرف مطابقًا لحرف أبجدي كبير بتنسيق UTF-8، يتم تمريره بدون تغيير.
أمثلة:
| القيمة | 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
البنية:
substring[T <: STRING | BYTES](input: T, position: INT64) -> T
substring[T <: STRING | BYTES](input: T, position: INT64, length: INT64) -> T
الوصف:
تعرض هذه الدالة سلسلة فرعية من input تبدأ عند position (فهرس يبدأ من الصفر) وتتضمّن ما يصل إلى length إدخالات. في حال عدم توفير length، يتم عرض السلسلة الفرعية من position إلى نهاية input.
إذا كانت
inputقيمةSTRING، يتم قياسpositionوlengthبنقاط رمز Unicode. إذا كانت قيمةBYTES، يتم قياسها بالبايت.إذا كانت قيمة
positionأكبر من طولinput، يتم عرض سلسلة فرعية فارغة. إذا كانpositionزائدlengthأكبر من طولinput، يتم اقتطاع السلسلة الفرعية إلى نهايةinput.إذا كانت قيمة
positionسالبة، يتم تحديد الموضع من نهاية الإدخال. إذا كان العدد السالبpositionأكبر من حجم الإدخال، يتم ضبط الموضع على صفر. يجب أن تكون قيمةlengthغير سالبة.
أمثلة:
في حال عدم توفّر length:
| إدخال | الموضع | substring(input, position) |
|---|---|---|
| "abc" | 0 | "abc" |
| "abc" | 1 | "bc" |
| "abc" | 3 | "" |
| "abc" | -1 | "c" |
| b"abc" | 1 | b"bc" |
عند توفير length:
| إدخال | الموضع | الطول | 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
البنية:
string_reverse[T <: STRING | BYTES](input: T) -> T
الوصف:
تعرض هذه الدالة الإدخال المقدَّم بترتيب عكسي.
يتم تحديد الأحرف من خلال نقاط رموز Unicode عندما يكون الإدخال STRING، ومن خلال وحدات البايت عندما يكون الإدخال قيمة BYTES.
أمثلة:
| إدخال | string_reverse(input) |
|---|---|
| "abc" | "cba" |
| "a🌹b" | "b🌹a" |
| "hello" | "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
البنية:
string_repeat[T <: STRING | BYTES](input: T, repetitions: INT64) -> T
الوصف:
تعرض input مكرّرة repetitions مرة.
- يجب أن يكون
repetitionsعددًا صحيحًا غير سالب. - إذا كانت
repetitionsهي0، تعرض الدالة قيمة فارغة من النوع نفسه مثلinput. - إذا تجاوزت النتيجة الحد الأقصى المسموح به للحجم (1 ميغابايت)، سيظهر خطأ.
أمثلة:
| إدخال | التكرارات | string_repeat(input, repetitions) |
|---|---|---|
| "foo" | 3 | "foofoofoo" |
| "foo" | 0 | "" |
| "a " | 3 | "a a a " |
| b"ab" | 2 | b"abab" |
| "é🦆" | 2 | "é🦆é🦆" |
STRING_REPLACE_ALL
البنية:
string_replace_all[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T
الوصف:
يستبدل جميع مثيلات find غير المتداخلة في input بـ replacement.
- تكون المطابقات حساسة لحالة الأحرف.
- إذا كان
findفارغًا، لن يتم إجراء أي عمليات استبدال.
أمثلة:
| إدخال | العثور | الاستبدال | 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
البنية:
string_replace_one[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T
الوصف:
يستبدل هذا الإجراء أول ظهور للقيمة find في input بالقيمة replacement.
- تكون المطابقات حساسة لحالة الأحرف.
- إذا كان
findفارغًا، لن يتم إجراء أي عمليات استبدال.
أمثلة:
| إدخال | العثور | الاستبدال | string_replace_one(input, find, replacement) |
|---|---|---|---|
| "foobarfoo" | "foo" | "baz" | "bazbarfoo" |
| "é" | "é" | "a" | "a" |
| b"foobar" | b"o" | b"z" | b"fzoobar" |
TRIM
البنية:
trim[T <: STRING | BYTES](input: T, values_to_trim: T) -> T
trim[T <: STRING | BYTES](input: T) -> T
الوصف:
تزيل هذه الدالة مجموعة محدّدة من BYTES أو CHARS من بداية ونهاية input المقدَّمة.
- في حال عدم توفير أي
values_to_trim، تتم إزالة أحرف المسافة البيضاء.
أمثلة:
في حال عدم توفّر values_to_trim:
| إدخال | 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:
| إدخال | قيم_الاقتطاع | trim(input, values_to_trim) |
|---|---|---|
| "abcbfooaacb" | "abc" | "foo" |
| "abcdaabadbac" | "abc" | "daabad" |
| b"C1C2C3" | b"C1" | b"C2C3" |
| b"C1C2" | "foo" | خطأ |
| "foo" | b"C1" | خطأ |
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
البنية:
ltrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
ltrim[T <: STRING | BYTES](value: T) -> T
الوصف:
تزيل هذه الدالة مجموعة محدّدة من BYTES أو CHARS من بداية value المقدَّمة.
- في حال عدم توفير
to_trim، يتم قطع المسافات البيضاء البادئة.
أمثلة:
في حال عدم توفّر to_trim:
| القيمة | ltrim(value) |
|---|---|
| " foo " | "foo " |
| "foo" | "foo" |
عند توفير to_trim:
| القيمة | to_trim | ltrim(value, to_trim) |
|---|---|---|
| "aaabc" | "a" | "bc" |
| "abacaba" | "ba" | "caba" |
| "é" | "é" | "" |
RTRIM
البنية:
rtrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
rtrim[T <: STRING | BYTES](value: T) -> T
الوصف:
تزيل هذه الدالة مجموعة محدّدة من BYTES أو CHARS من نهاية value المقدَّمة.
- في حال عدم توفير
to_trim، يتم قطع أحرف المسافة البيضاء اللاحقة.
أمثلة:
في حال عدم توفّر to_trim:
| القيمة | rtrim(value) |
|---|---|
| " foo " | " foo" |
| "foo" | "foo" |
عند توفير to_trim:
| القيمة | to_trim | rtrim(value, to_trim) |
|---|---|---|
| "abccc" | "c" | "ab" |
| "abacaba" | "ba" | "abac" |
| "é" | "é" | "" |
SPLIT
البنية:
split(input: STRING) -> ARRAY<STRING>
split[T <: STRING | BYTES](input: T, delimiter: T) -> ARRAY<T>
الوصف:
تقسيم قيمة STRING أو BYTES باستخدام محدّد
بالنسبة إلى
STRING، يكون المحدّد التلقائي هو الفاصلة,. يتم التعامل مع المُحدِّد كسلسلة واحدة.بالنسبة إلى
BYTES، يجب تحديد محدّد.يؤدي التقسيم باستخدام محدد فارغ إلى إنشاء صفيف من نقاط الرموز Unicode لقيم
STRING، وصفيف منBYTESلقيمBYTES.يؤدي تقسيم
STRINGفارغ إلى عرضARRAYيحتوي علىSTRINGفارغ واحد.
أمثلة:
في حال عدم توفّر delimiter:
| إدخال | split(input) |
|---|---|
| "foo,bar,foo" | ["foo", "bar", "foo"] |
| "foo" | ["foo"] |
| ",foo," | ["", "foo", ""] |
| "" | [""] |
| b"C120C2C4" | خطأ |
عند توفير delimiter:
| إدخال | المحدِّد | 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" | خطأ |