स्ट्रिंग फ़ंक्शन

स्ट्रिंग फ़ंक्शन

नाम ब्यौरा
BYTE_LENGTH STRING या BYTES वैल्यू में 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 वैल्यू की पहली एंट्री का 0-आधारित इंडेक्स दिखाता है.
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

जानकारी:

STRING या BYTES वैल्यू में BYTES की संख्या दिखाता है.

प्रॉम्प्ट के उदाहरण:

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();
जाएं
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 वैल्यू में यूनिकोड कोड पॉइंट की संख्या दिखाता है.

प्रॉम्प्ट के उदाहरण:

value 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();
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();
जाएं
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.CharLength(firestore.FieldOf("title")).As("titleCharLength"),
	)).
	Execute(ctx)

STARTS_WITH

सिंटैक्स:

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

जानकारी:

अगर value, prefix से शुरू होता है, तो TRUE वैल्यू मिलती है.

प्रॉम्प्ट के उदाहरण:

value उपसर्ग 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();
जाएं
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 वैल्यू मिलती है.

प्रॉम्प्ट के उदाहरण:

value पोस्टफ़िक्स 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();
जाएं
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 दिखाता है.

प्रॉम्प्ट के उदाहरण:

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();
जाएं
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("pattern", "options") का इस्तेमाल करके बनाई गई REGEX वैल्यू भी हो सकती है. इस फ़ॉर्मैट की मदद से, पैटर्न के साथ रेगुलर एक्सप्रेशन के विकल्प दिए जा सकते हैं. ये विकल्प इस्तेमाल किए जा सकते हैं:

  • i: केस-इनसेंसिटिव मैचिंग.
  • m: मल्टी-लाइन मोड (^ और $, लाइनों की शुरुआत या आखिर से मैच करते हैं).
  • s: Dotall मोड (. नई लाइनों से मैच करता है).

अगर regexp एक STRING है, तो पैटर्न में एम्बेड किए गए विकल्पों के अलावा कोई और विकल्प लागू नहीं होता. उदाहरण के लिए, (?i).

रेगुलर एक्सप्रेशन, re2 लाइब्रेरी के सिंटैक्स का पालन करते हैं.

प्रॉम्प्ट के उदाहरण:

value regexp regex_contains(value, regexp)
"Firestore" "फ़ायर" सही
"Firestore" "store$" सही
"Firestore" "data" गलत
"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();
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();
जाएं
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("pattern", "options") का इस्तेमाल करके बनाई गई REGEX वैल्यू भी हो सकती है. इस फ़ॉर्मैट की मदद से, पैटर्न के साथ रेगुलर एक्सप्रेशन के विकल्प दिए जा सकते हैं. ये विकल्प इस्तेमाल किए जा सकते हैं:

  • i: केस-इनसेंसिटिव मैचिंग.
  • m: मल्टी-लाइन मोड (^ और $, लाइनों की शुरुआत या आखिर से मैच करते हैं).
  • s: Dotall मोड (. नई लाइनों से मैच करता है).

अगर regexp एक STRING है, तो पैटर्न में एम्बेड किए गए विकल्पों के अलावा कोई और विकल्प लागू नहीं होता. उदाहरण के लिए, (?i).

रेगुलर एक्सप्रेशन, re2 लाइब्रेरी के सिंटैक्स का पालन करते हैं.

प्रॉम्प्ट के उदाहरण:

value regexp 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("pattern", "options") का इस्तेमाल करके बनाई गई REGEX वैल्यू भी हो सकती है. इस फ़ॉर्मैट की मदद से, पैटर्न के साथ रेगुलर एक्सप्रेशन के विकल्प दिए जा सकते हैं. ये विकल्प इस्तेमाल किए जा सकते हैं:

  • i: केस-इनसेंसिटिव मैचिंग.
  • m: मल्टी-लाइन मोड (^ और $, लाइनों की शुरुआत या आखिर से मैच करते हैं).
  • s: Dotall मोड (. नई लाइनों से मैच करता है).

अगर regexp एक STRING है, तो पैटर्न में एम्बेड किए गए विकल्पों के अलावा कोई और विकल्प लागू नहीं होता. उदाहरण के लिए, (?i).

रेगुलर एक्सप्रेशन, re2 लाइब्रेरी के सिंटैक्स का पालन करते हैं.

प्रॉम्प्ट के उदाहरण:

value regexp regex_find_all(value, regexp)
"एक दो तीन दो" "one" "एक"
"एक दो तीन दो" regex("two", "i") "दो"
"एक दो तीन दो" regex("TWO", "") []

REGEX_MATCH

सिंटैक्स:

regex_match(value: STRING, regexp: STRING | REGEX) -> BOOLEAN

जानकारी:

अगर value, regexp से पूरी तरह मैच होता है, तो TRUE दिखाता है. अगर regexp कोई मान्य रेगुलर एक्सप्रेशन नहीं है, तो यह फ़ंक्शन error दिखाता है.

regexp आर्ग्युमेंट, regex("pattern", "options") का इस्तेमाल करके बनाई गई REGEX वैल्यू भी हो सकती है. इस फ़ॉर्मैट की मदद से, पैटर्न के साथ रेगुलर एक्सप्रेशन के विकल्प दिए जा सकते हैं. ये विकल्प इस्तेमाल किए जा सकते हैं:

  • i: केस-इनसेंसिटिव मैचिंग.
  • m: मल्टी-लाइन मोड (^ और $, लाइनों की शुरुआत या आखिर से मैच करते हैं).
  • s: Dotall मोड (. नई लाइनों से मैच करता है).

अगर regexp एक STRING है, तो पैटर्न में एम्बेड किए गए विकल्पों के अलावा कोई और विकल्प लागू नहीं होता. उदाहरण के लिए, (?i).

रेगुलर एक्सप्रेशन, re2 लाइब्रेरी के सिंटैक्स का पालन करते हैं.

प्रॉम्प्ट के उदाहरण:

value regexp 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();
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();
जाएं
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();
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();
जाएं
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 शामिल है या नहीं.

प्रॉम्प्ट के उदाहरण:

value सबस्ट्रिंग string_contains(value, substring)
"abc" "b" सही
"abc" "d" गलत
"abc" "" सही
"एसी" "." सही
"☃☃☃" "☃" सही
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();
जाएं
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

जानकारी:

value में search की पहली एंट्री का 0-आधारित इंडेक्स दिखाता है.

  • अगर search नहीं मिलता है, तो -1 दिखाता है.
  • अगर value एक STRING वैल्यू है, तो नतीजे को यूनिकोड कोड पॉइंट में मेज़र किया जाता है. अगर यह BYTES वैल्यू है, तो इसे बाइट में मेज़र किया जाता है.
  • अगर search की वैल्यू खाली STRING या BYTES है, तो नतीजा 0 होगा.

प्रॉम्प्ट के उदाहरण:

value खोजें string_index_of(value, search)
"नमस्ते" "o" 4
"नमस्ते" "l" 2
"नमस्ते" "z" -1
"केला" "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 के अंग्रेज़ी के छोटे अक्षर से मेल नहीं खाता है, तो उसे बिना किसी बदलाव के पास कर दिया जाता है.

प्रॉम्प्ट के उदाहरण:

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();
जाएं
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 के अंग्रेज़ी के बड़े अक्षर से मेल नहीं खाता है, तो उसे बिना किसी बदलाव के पास कर दिया जाता है.

प्रॉम्प्ट के उदाहरण:

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();
जाएं
snapshot := client.Pipeline().
	Collection("authors").
	Select(firestore.Fields(
		firestore.Equal(firestore.ToLower(firestore.FieldOf("genre")), "fantasy").As("isFantasy"),
	)).
	Execute(ctx)

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 को यूनिकोड कोड पॉइंट में मेज़र किया जाता है. अगर यह 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();
जाएं
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();
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();
जाएं
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 के टाइप की खाली वैल्यू दिखाता है.
  • अगर नतीजे का साइज़, तय किए गए साइज़ (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

जानकारी:

input में मौजूद, ओवरलैप न होने वाले find के सभी इंस्टेंस को 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

जानकारी:

input में find की पहली मौजूदगी को 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

जानकारी:

यह फ़ंक्शन, दिए गए input की शुरुआत और आखिर से, BYTES या CHARS के सेट को ट्रिम करता है.

  • अगर कोई 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();
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();
जाएं
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

जानकारी:

यह फ़ंक्शन, दिए गए value की शुरुआत से BYTES या CHARS के सेट को ट्रिम करता है.

  • अगर to_trim नहीं दिया गया है, तो शुरुआत में मौजूद व्हाइटस्पेस कैरेक्टर को हटा देता है.

प्रॉम्प्ट के उदाहरण:

to_trim न देने पर:

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

to_trim की वैल्यू देने पर:

value 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

जानकारी:

यह फ़ंक्शन, दी गई value के आखिर से BYTES या CHARS के सेट को हटाता है.

  • अगर to_trim नहीं दिया गया है, तो आखिर में मौजूद खाली सफ़ेद जगह को हटा देता है.

प्रॉम्प्ट के उदाहरण:

to_trim न देने पर:

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

to_trim की वैल्यू देने पर:

value 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 को स्प्लिट करने पर, एक खाली STRING वाला ARRAY मिलता है.

प्रॉम्प्ट के उदाहरण:

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" गड़बड़ी