توابع رشته
| نام | شرح |
BYTE_LENGTH
|
تعداد BYTES را در مقدار STRING یا BYTES برمیگرداند
|
CHAR_LENGTH
|
تعداد نویسههای یونیکد را در مقدار STRING برمیگرداند
|
STARTS_WITH
|
اگر STRING با پیشوند دادهشده شروع شود، TRUE را برمیگرداند
|
ENDS_WITH
|
اگر STRING با پسوند دادهشدهای پایان یابد، TRUE را برمیگرداند
|
LIKE
|
اگر STRING با الگویی مطابقت داشته باشد، TRUE را برمیگرداند
|
REGEX_CONTAINS
|
اگر مقداری با عبارت باقاعده مطابقت کامل یا جزئی داشته باشد، TRUE را برمیگرداند
|
REGEX_FIND
|
اولین رشته فرعی را که با عبارت باقاعده مطابقت دارد برمیگرداند، یا اگر مطابقت نداشته باشد، NULL را برمیگرداند.
|
REGEX_FIND_ALL
|
آرایهای از همه رشتههای فرعی را که با عبارت باقاعده مطابقت دارند برمیگرداند، یا اگر مطابقت وجود نداشته باشد، آرایه خالی برمیگرداند. |
REGEX_MATCH
|
اگر هر بخشی از مقدار با عبارت باقاعده مطابقت داشته باشد، TRUE را برمیگرداند
|
STRING_CONCAT
|
چند STRING را در یک STRING بههم متصل میکند
|
STRING_CONTAINS
|
اگر مقدار حاوی STRING باشد، TRUE را برمیگرداند
|
STRING_INDEX_OF
|
نمایه مبتنی بر ۰ اولین رخداد مقدار 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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").byte_length().as_("titleByteLength")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(byteLength(field("title")).as("titleByteLength")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ByteLength(firestore.FieldOf("title")).As("titleByteLength"), )). Execute(ctx)
CHAR_LENGTH
نحو:
char_length(value: STRING) -> INT64
شرح:
تعداد نقاط کد یونیکد را در مقدار STRING برمیگرداند.
نمونه:
| مقدار | char_length(value) |
|---|---|
| «abc» | 3 |
| «سلام» | 5 |
| «جهان» | 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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").char_length().as_("titleCharLength")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(charLength(field("title")).as("titleCharLength")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.CharLength(firestore.FieldOf("title")).As("titleCharLength"), )). Execute(ctx)
شروع میشود با
نحو:
starts_with(value: STRING, prefix: STRING) -> BOOLEAN
شرح:
اگر value با prefix شروع شود، TRUE را برمیگرداند.
نمونه:
| مقدار | پیشوند | 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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("title").starts_with("The").as_("needsSpecialAlphabeticalSort") ) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(startsWith(field("title"), "The").as("needsSpecialAlphabeticalSort")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.StartsWith(firestore.FieldOf("title"), "The").As("needsSpecialAlphabeticalSort"), )). Execute(ctx)
ENDS_WITH
نحو:
ends_with(value: STRING, postfix: STRING) -> BOOLEAN
شرح:
اگر value با postfix پایان یابد، TRUE را برمیگرداند.
نمونه:
| مقدار | پسوند | 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();
پایتون
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() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("inventory/devices/laptops") .select(endsWith(field("name"), "16 inch").as("16InLaptops")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("inventory/devices/laptops"). Select(firestore.Fields( firestore.EndsWith(firestore.FieldOf("name"), "16 inch").As("`Laptops16in`"), )). Execute(ctx)
پسندیدن
نحو:
like(value: STRING, pattern: STRING) -> BOOLEAN
شرح:
اگر value با pattern مطابقت داشته باشد، TRUE را برمیگرداند.
نمونه:
| مقدار | الگو | like(value, pattern) |
|---|---|---|
| «Firestore» | «آتش%» | درست |
| «Firestore» | «%store» | درست |
| «Datastore» | «Data_tore» | درست |
| «۱۰۰٪» | «۱۰۰٪» | درست |
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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").like("%Fiction").as_("anyFiction")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(like(field("genre"), "%Fiction").as("anyFiction")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Like(firestore.FieldOf("genre"), "%Fiction").As("anyFiction"), )). Execute(ctx)
REGEX_CONTAINS
نحو:
regex_contains(value: STRING, regexp: STRING | REGEX) -> BOOLEAN
شرح:
اگر بخشی از value با regexp مطابقت داشته باشد، TRUE را برمیگرداند. اگر regexp عبارت باقاعده معتبری نباشد، این تابع error برمیگرداند.
آرگومان regexp میتواند مقدار REGEX ایجادشده بااستفاده از
regex("pattern", "options") نیز باشد. این قالب به شما امکان میدهد گزینههای عبارت باقاعده را
همراه با الگو ارائه دهید. گزینههای پشتیبانیشده عبارتاند از:
-
i: مطابقت غیرحساس به حروف. m: حالت چندخطی (^و$با شروع یا پایان خطوط مطابقت دارد).s: حالت Dotall (.با خطهای جدید مطابقت دارد).
اگر regexp یک STRING باشد، هیچ گزینهای غیراز گزینههای جاسازیشده در خود الگو (مثلاً (?i)) اعمال نمیشود.
عبارتهای باقاعده از نحو کتابخانه re2 پیروی میکنند.
نمونه:
| مقدار | عبارت باقاعده | regex_contains(value, regexp) |
|---|---|---|
| «Firestore» | «آتش» | درست |
| «Firestore» | "store$" | درست |
| «Firestore» | «داده» | نادرست |
| «Firestore» | regex("fire", "i") |
درست |
| «Firestore» | regex("FIRE", "") |
نادرست |
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();
پایتون
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() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select( regexContains(field("title"), "Firestore (Enterprise|Standard)") .as("isFirestoreRelated")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.RegexContains(firestore.FieldOf("title"), "Firestore (Enterprise|Standard)").As("isFirestoreRelated"), )). Execute(ctx)
REGEX_FIND
نحو:
regex_find(value: STRING, regexp: STRING | REGEX) -> STRING
شرح:
اولین زیررشته را در value که با regexp مطابقت دارد برمیگرداند، یا اگر موردی منطبق نباشد، NULL را برمیگرداند. اگر regexp عبارت باقاعده معتبری نباشد، این تابع
error برمیگرداند.
آرگومان regexp میتواند مقدار REGEX ایجادشده بااستفاده از
regex("pattern", "options") نیز باشد. این قالب به شما امکان میدهد گزینههای عبارت باقاعده را
همراه با الگو ارائه دهید. گزینههای پشتیبانیشده عبارتاند از:
-
i: مطابقت غیرحساس به حروف. m: حالت چندخطی (^و$با شروع یا پایان خطوط مطابقت دارد).s: حالت Dotall (.با خطهای جدید مطابقت دارد).
اگر regexp یک STRING باشد، هیچ گزینهای غیراز گزینههای جاسازیشده در خود الگو (مثلاً (?i)) اعمال نمیشود.
عبارتهای باقاعده از نحو کتابخانه re2 پیروی میکنند.
نمونه:
| مقدار | عبارت باقاعده | regex_find(value, regexp) |
|---|---|---|
| "Sometext MATCH" | «SomeText» | «Sometext» |
| "Sometext MATCH" | regex("match", "i") |
«MATCH» |
| "Sometext MATCH" | regex("(match)", "i") |
«MATCH» |
| «Sometext match» | regex("MATCH", "") |
تهی |
REGEX_FIND_ALL
نحو:
regex_find_all(value: STRING, regexp: STRING | REGEX) -> ARRAY<STRING>
شرح:
آرایهای از همه زیررشتهها در value را که با regexp مطابقت دارند برمیگرداند، یا اگر موردی منطبق نباشد، آرایهای خالی برمیگرداند. اگر regexp عبارت باقاعده معتبری نباشد،
این تابع error برمیگرداند.
آرگومان regexp میتواند مقدار REGEX ایجادشده بااستفاده از
regex("pattern", "options") نیز باشد. این قالب به شما امکان میدهد گزینههای عبارت باقاعده را
همراه با الگو ارائه دهید. گزینههای پشتیبانیشده عبارتاند از:
-
i: مطابقت غیرحساس به حروف. m: حالت چندخطی (^و$با شروع یا پایان خطوط مطابقت دارد).s: حالت Dotall (.با خطهای جدید مطابقت دارد).
اگر regexp یک STRING باشد، هیچ گزینهای غیراز گزینههای جاسازیشده در خود الگو (مثلاً (?i)) اعمال نمیشود.
عبارتهای باقاعده از نحو کتابخانه re2 پیروی میکنند.
نمونه:
| مقدار | عبارت باقاعده | regex_find_all(value, regexp) |
|---|---|---|
| «یک دو سه دو» | «یک» | ["one"] |
| «یک دو سه دو» | regex("two", "i") |
["TWO", "Two"] |
| «یک دو سه دو» | regex("TWO", "") |
[زود میآیی][زود میآیین][زود میآیی][زود میآیین][الآن میآیی][الآن میآیین][الآن میایی][الآن میایین][چقدر دیگه میرسی][چقدر دیگه میرسین][کی میرسی][کی میرسین][کی میرسید][کی میرسی اینجا][کی میرسین اینجا][کی میرسید اینجا][کی میرسی آنجا][کی میرسین آنجا][کی میرسید آنجا][کی میرسی اونجا][کی میرسین اونجا][کی میرسید اونجا][کی اینجا میرسی][کی اینجا میرسین][کی اینجا میرسید][کی میرسی اینجا][کی میرسین اینجا][کی میرسید اینجا][کی فکر میکنی میرسی][کی فکر میکنی میرسین][کی فکر میکنی میرسید][کی فکر میکنی میرسی][کی فکر میکنی میرسین][کی فکر میکنی میرسید][تا کی میرسی][تا کی میرسین][تا کی میرسید][چقدر دیگه میرسی][چقدر دیگه میرسین][چقدر دیگه میرسید][فکر میکنی چقدر دیگه برسی][فکر میکنی چقدر دیگه برسین][فکر میکنی چقدر دیگه برسی][حدوداً کی میرسی][حدوداً کی میرسین][حدوداً کی میرسید][کی فکر میکنی اینجایی][کی فکر میکنی اینجایین][کی فکر میکنی اینجایید][کی فکر میکنی اونجایی][کی فکر میکنی اونجایی][کی فکر میکنی اونجایید][چند دقیقه دیگه؟][کی؟][حدوداً؟][فکر میکنی چقدر دیگه برسی][[فکر میکنی چقدر دیگه برسین][فکر میکنی چقدر دیگه برسید]فکر میکنی چند دقیقه دیگه؟][فکرمیکنی کی؟][فکر میکنی چند دقیقه دیگه؟][فکرمیکنی کی؟][فکر میکنی چند دقیقه دیگه؟][زمان تقریبی ورود؟][زمان تقریبی رسیدن؟][تقریباً؟][نزدیکی؟][چقدر دیگه؟][کی؟][اینجا؟][اونجا؟][آنجا؟][سر میدونی؟][سر میدونین؟][سر کوچهای؟][سر کوچهاین؟][پشت دری؟][پشت درین؟][حالا؟] |
REGEX_MATCH
نحو:
regex_match(value: STRING, regexp: STRING | REGEX) -> BOOLEAN
شرح:
اگر value کاملاً با regexp مطابقت داشته باشد، TRUE را برمیگرداند. اگر regexp عبارت باقاعده معتبری نباشد، این تابع error برمیگرداند.
آرگومان regexp میتواند مقدار REGEX ایجادشده بااستفاده از
regex("pattern", "options") نیز باشد. این قالب به شما امکان میدهد گزینههای عبارت باقاعده را
همراه با الگو ارائه دهید. گزینههای پشتیبانیشده عبارتاند از:
-
i: مطابقت غیرحساس به حروف. m: حالت چندخطی (^و$با شروع یا پایان خطوط مطابقت دارد).s: حالت Dotall (.با خطهای جدید مطابقت دارد).
اگر regexp یک STRING باشد، هیچ گزینهای غیراز گزینههای جاسازیشده در خود الگو (مثلاً (?i)) اعمال نمیشود.
عبارتهای باقاعده از نحو کتابخانه re2 پیروی میکنند.
نمونه:
| مقدار | عبارت باقاعده | regex_match(value, regexp) |
|---|---|---|
| «Firestore» | "F.*store" | درست |
| «Firestore» | «آتش» | نادرست |
| «Firestore» | "^F.*e$" | درست |
| "FiReStOrE" | regex("firestore", "i") |
درست |
| «Firestore» | regex("firestore", "") |
نادرست |
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();
پایتون
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() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select( regexMatch(field("title"), "Firestore (Enterprise|Standard)") .as("isFirestoreExactly")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.RegexMatch(firestore.FieldOf("title"), "Firestore (Enterprise|Standard)").As("isFirestoreExactly"), )). Execute(ctx)
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();
پایتون
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() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(stringConcat(field("title"), " by ", field("author")).as("fullyQualifiedTitle")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.StringConcat(firestore.FieldOf("title"), " by ", firestore.FieldOf("author")).As("fullyQualifiedTitle"), )). Execute(ctx)
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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("articles") .select(Field.of("body").string_contains("Firestore").as_("isFirestoreRelated")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("articles") .select(stringContains(field("body"), "Firestore").as("isFirestoreRelated")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("articles"). Select(firestore.Fields( firestore.StringContains(firestore.FieldOf("body"), "Firestore").As("isFirestoreRelated"), )). Execute(ctx)
STRING_INDEX_OF
نحو:
string_index_of[T <: STRING | BYTES](value: T, search: T) -> INT64
شرح:
نمایه مبتنی بر ۰ اولین رخداد search را در value برمیگرداند.
- اگر
searchپیدا نشود،-1را برمیگرداند. - اگر
valueمقدارSTRINGباشد، نتیجه در نقاط کد یونیکد اندازهگیری میشود. اگر مقدارBYTESباشد، با بایت اندازهگیری میشود. - اگر
searchمقدارSTRINGیاBYTESخالی باشد، نتیجه0است.
نمونه:
| مقدار | جستجو | string_index_of(value, search) |
|---|---|---|
| "hello world" | «o» | 4 |
| "hello world" | «l» | 2 |
| "hello world" | «z» | ۱- |
| «موز» | «ana» | 1 |
| «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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("authors") .select(Field.of("name").to_upper().as_("uppercaseName")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("authors") .select(toUpper(field("name")).as("uppercaseName")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("authors"). Select(firestore.Fields( firestore.ToUpper(firestore.FieldOf("name")).As("uppercaseName"), )). Execute(ctx)
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();
پایتون
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() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("authors") .select(equal(toLower(field("genre")), "fantasy").as("isFantasy")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("authors"). Select(firestore.Fields( firestore.Equal(firestore.ToLower(firestore.FieldOf("genre")), "fantasy").As("isFantasy"), )). Execute(ctx)
رشته فرعی
نحو:
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در نقاط کد یونیکد اندازهگیری میشوند. اگر مقدارBYTESباشد، با بایت اندازهگیری میشود.اگر
positionبزرگتر از طولinputباشد، رشته فرعی خالی برگردانده میشود. اگرpositionبهعلاوهlengthبزرگتر از طولinputباشد، رشته فرعی تا انتهایinputکوتاه میشود.اگر
positionمنفی باشد، موقعیت از انتهای ورودی گرفته میشود. اگرpositionمنفی بزرگتر از اندازه ورودی باشد، موقعیت روی صفر تنظیم میشود.lengthباید غیرمنفی باشد.
نمونه:
وقتی length ارائه نشده باشد:
| ورودی | جایگاه | substring(input, position) |
|---|---|---|
| «abc» | 0 | «abc» |
| «abc» | 1 | «bc» |
| «abc» | 3 | "" |
| «abc» | ۱- | «c» |
| b"abc" | 1 | b"bc" |
وقتی length ارائه میشود:
| ورودی | جایگاه | طول | substring(input, position, length) |
|---|---|---|---|
| «abc» | 0 | 1 | «a» |
| «abc» | 1 | 2 | «bc» |
| «abc» | ۱- | 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();
پایتون
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() )
جاوا
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();
رفتن
snapshot := client.Pipeline(). Collection("books"). Where(firestore.StartsWith(firestore.FieldOf("title"), "The ")). Select(firestore.Fields( firestore.Substring(firestore.FieldOf("title"), firestore.ConstantOf(4), firestore.FieldOf("title").CharLength()).As("titleWithoutLeadingThe"), )). Execute(ctx)
STRING_REVERSE
نحو:
string_reverse[T <: STRING | BYTES](input: T) -> T
شرح:
ورودی ارائهشده را بهترتیب معکوس برمیگرداند.
وقتی ورودی STRING باشد، نویسهها با نقاط کد یونیکد مشخص میشوند،
و وقتی ورودی مقدار BYTES باشد، با بایت مشخص میشوند.
نمونه:
| ورودی | string_reverse(input) |
|---|---|
| «abc» | «cba» |
| «a🌹b» | "b🌹a" |
| «سلام» | «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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("name").string_reverse().as_("reversedName")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(reverse(field("name")).as("reversedName")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Reverse(firestore.FieldOf("name")).As("reversedName"), )). Execute(ctx)
STRING_REPEAT
نحو:
string_repeat[T <: STRING | BYTES](input: T, repetitions: INT64) -> T
شرح:
input را که repetitions بار تکرار شده است برمیگرداند.
-
repetitionsباید عدد صحیح غیرمنفی باشد. - اگر
repetitionsبرابر با0باشد، مقدار خالی از همان نوعinputرا برمیگرداند. - اگر نتیجه از حداکثر اندازه مجاز (۱ مگابایت) فراتر برود، خطا برگردانده میشود.
نمونه:
| ورودی | تکرار | 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[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 ارائه میشود:
| ورودی | 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();
پایتون
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("name").trim().as_("whitespaceTrimmedName")) .execute() )
جاوا
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(trim(field("name")).as("whitespaceTrimmedName")) .execute() .get();
رفتن
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Trim(firestore.FieldOf("name")).As("whitespaceTrimmedName"), )). Execute(ctx)
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(input: STRING) -> ARRAY<STRING>
split[T <: STRING | BYTES](input: T, delimiter: T) -> ARRAY<T>
شرح:
مقدار STRING یا BYTES را بااستفاده از جداکننده تقسیم میکند.
برای
STRING، جداکننده پیشفرض ویرگول,است. جداکننده بهعنوان یک رشته واحد درنظر گرفته میشود.برای
BYTES، باید حائل مشخص کنید.تقسیم کردن روی جداکننده خالی آرایهای از کدپوینتهای «یونیکد» برای مقادیر
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" | خطا |