एग्रीगेट
सभी एग्रीगेट फ़ंक्शन को aggregate(...) स्टेज में टॉप-लेवल एक्सप्रेशन के तौर पर इस्तेमाल किया जा सकता है.
| नाम | ब्यौरा |
COUNT
|
दस्तावेज़ों की संख्या दिखाता है. |
COUNT_IF
|
उन दस्तावेज़ों की संख्या दिखाता है जिनमें किसी एक्सप्रेशन की वैल्यू TRUE होती है
|
COUNT_DISTINCT
|
यह फ़ंक्शन, यूनीक और ऐसी वैल्यू की संख्या दिखाता है जो NULL नहीं हैं
|
SUM
|
सभी NUMERIC वैल्यू का योग दिखाता है
|
AVERAGE
|
सभी NUMERIC वैल्यू का औसत दिखाता है
|
MINIMUM
|
NULL के अलावा, सबसे कम वैल्यू दिखाता है
|
MAXIMUM
|
यह फ़ंक्शन, NULL के अलावा सबसे ज़्यादा वैल्यू दिखाता है
|
FIRST
|
यह पहले दस्तावेज़ के लिए, expression वैल्यू दिखाता है.
|
LAST
|
यह आखिरी दस्तावेज़ के लिए, expression वैल्यू दिखाता है.
|
ARRAY_AGG
|
यह सभी इनपुट वैल्यू का कलेक्शन दिखाता है. |
ARRAY_AGG_DISTINCT
|
यह सभी अलग-अलग इनपुट वैल्यू का ऐरे दिखाता है. |
COUNT
सिंटैक्स:
count() -> INT64
count(expression: ANY) -> INT64
जानकारी:
यह फ़ंक्शन, पिछले चरण के उन दस्तावेज़ों की संख्या दिखाता है जिनमें expression की वैल्यू, NULL के अलावा कुछ और होती है. अगर कोई expression नहीं दिया जाता है, तो पिछले चरण के दस्तावेज़ों की कुल संख्या दिखाता है.
Node.js
// Total number of books in the collection const countOfAll = await db.pipeline() .collection("books") .aggregate(countAll().as("count")) .execute(); // Number of books with nonnull `ratings` field const countField = await db.pipeline() .collection("books") .aggregate(field("ratings").count().as("count")) .execute();
Web
// Total number of books in the collection const countOfAll = await execute(db.pipeline() .collection("books") .aggregate(countAll().as("count")) ); // Number of books with nonnull `ratings` field const countField = await execute(db.pipeline() .collection("books") .aggregate(field("ratings").count().as("count")) );
Swift
// Total number of books in the collection let countAll = try await db.pipeline() .collection("books") .aggregate([CountAll().as("count")]) .execute() // Number of books with nonnull `ratings` field let countField = try await db.pipeline() .collection("books") .aggregate([Field("ratings").count().as("count")]) .execute()
Kotlin
// Total number of books in the collection val countAll = db.pipeline() .collection("books") .aggregate(AggregateFunction.countAll().alias("count")) .execute() // Number of books with nonnull `ratings` field val countField = db.pipeline() .collection("books") .aggregate(AggregateFunction.count("ratings").alias("count")) .execute()
Java
// Total number of books in the collection Task<Pipeline.Snapshot> countAll = db.pipeline() .collection("books") .aggregate(AggregateFunction.countAll().alias("count")) .execute(); // Number of books with nonnull `ratings` field Task<Pipeline.Snapshot> countField = db.pipeline() .collection("books") .aggregate(AggregateFunction.count("ratings").alias("count")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Count # Total number of books in the collection count_all = ( client.pipeline().collection("books").aggregate(Count().as_("count")).execute() ) # Number of books with nonnull `ratings` field count_field = ( client.pipeline() .collection("books") .aggregate(Count("ratings").as_("count")) .execute() )
Java
// Total number of books in the collection Pipeline.Snapshot countAll = firestore.pipeline().collection("books").aggregate(countAll().as("count")).execute().get(); // Number of books with nonnull `ratings` field Pipeline.Snapshot countField = firestore .pipeline() .collection("books") .aggregate(count("ratings").as("count")) .execute() .get();
जाएं
// Total number of books in the collection countAll, err := client.Pipeline().Collection("books"). Aggregate(firestore.Accumulators(firestore.CountAll().As("count"))). Execute(ctx).Results().GetAll() if err != nil { fmt.Fprintf(w, "GetAll failed: %v", err) return err } // Number of books with nonnull `ratings` field countField, err := client.Pipeline(). Collection("books"). Aggregate(firestore.Accumulators(firestore.Count("ratings").As("count"))). Execute(ctx).Results().GetAll() if err != nil { fmt.Fprintf(w, "GetAll failed: %v", err) return err }
COUNT_IF
सिंटैक्स:
count_if(expression: BOOLEAN) -> INT64
जानकारी:
पिछले चरण के उन दस्तावेज़ों की संख्या दिखाता है जहां expression की वैल्यू TRUE है.
Node.js
const result = await db.pipeline() .collection("books") .aggregate( field("rating").greaterThan(4).countIf().as("filteredCount") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .aggregate( field("rating").greaterThan(4).countIf().as("filteredCount") ) );
Swift
let result = try await db.pipeline() .collection("books") <<<<<<< HEAD .aggregate([ AggregateFunction(functionName: "count_if", args: [Field("rating").greaterThan(4)]).as("filteredCount") ]) ======= .aggregate([Field("rating").greaterThan(4).countIf().as("filteredCount")]) >>>>>>> master .execute()
Kotlin
val result = db.pipeline() .collection("books") .aggregate( AggregateFunction.countIf(field("rating").greaterThan(4)).alias("filteredCount") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .aggregate( AggregateFunction.countIf(field("rating").greaterThan(4)).alias("filteredCount") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("rating").greater_than(4).count_if().as_("filteredCount")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(countIf(field("rating").greaterThan(4)).as("filteredCount")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Aggregate(firestore.Accumulators( firestore.CountIf(firestore.FieldOf("rating").GreaterThan(4)).As("filteredCount"), )). Execute(ctx)
COUNT_DISTINCT
सिंटैक्स:
count_distinct(expression: ANY) -> INT64
जानकारी:
expression की ऐसी यूनीक वैल्यू की संख्या दिखाता है जो न तो NULL हैं और न ही ABSENT.
Node.js
const result = await db.pipeline() .collection("books") .aggregate(field("author").countDistinct().as("unique_authors")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .aggregate(field("author").countDistinct().as("unique_authors")) );
Swift
let result = try await db.pipeline() .collection("books") <<<<<<< HEAD .aggregate([AggregateFunction(functionName: "count_distinct", args: [Field("author")]).as("unique_authors")]) ======= .aggregate([Field("author").countDistinct().as("unique_authors")]) >>>>>>> master .execute()
Kotlin
val result = db.pipeline() .collection("books") .aggregate(AggregateFunction.countDistinct("author").alias("unique_authors")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .aggregate(AggregateFunction.countDistinct("author").alias("unique_authors")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("author").count_distinct().as_("unique_authors")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(countDistinct("author").as("unique_authors")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Aggregate(firestore.Accumulators( firestore.CountDistinct("author").As("unique_authors"), )). Execute(ctx)
SUM
सिंटैक्स:
sum(expression: ANY) -> NUMBER
जानकारी:
यह फ़ंक्शन, अंकों वाली सभी वैल्यू का योग दिखाता है. साथ ही, बिना अंकों वाली वैल्यू को अनदेखा करता है. अगर कोई भी वैल्यू NaN है, तो NaN दिखाता है.
आउटपुट का टाइप, सबसे बड़े इनपुट टाइप जैसा ही होगा. हालांकि, इन मामलों में ऐसा नहीं होगा:
- अगर किसी
INTEGERकोINTEGERके तौर पर नहीं दिखाया जा सकता, तो उसेDOUBLEमें बदल दिया जाएगा.
Node.js
const result = await db.pipeline() .collection("cities") .aggregate(field("population").sum().as("totalPopulation")) .execute();
Web
const result = await execute(db.pipeline() .collection("cities") .aggregate(field("population").sum().as("totalPopulation")) );
Swift
let result = try await db.pipeline() .collection("cities") .aggregate([Field("population").sum().as("totalPopulation")]) .execute()
Kotlin
val result = db.pipeline() .collection("cities") .aggregate(AggregateFunction.sum("population").alias("totalPopulation")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("cities") .aggregate(AggregateFunction.sum("population").alias("totalPopulation")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("cities") .aggregate(Field.of("population").sum().as_("totalPopulation")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("cities") .aggregate(sum("population").as("totalPopulation")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("cities"). Aggregate(firestore.Accumulators( firestore.Sum("population").As("totalPopulation"), )). Execute(ctx)
औसत
सिंटैक्स:
average(expression: ANY) -> FLOAT64
जानकारी:
यह फ़ंक्शन, बिना संख्या वाली वैल्यू को छोड़कर, सभी संख्या वाली वैल्यू का औसत दिखाता है.
अगर कोई भी वैल्यू NaN है, तो NaN दिखाता है. अगर कोई भी संख्या वाली वैल्यू एग्रीगेट नहीं की गई है, तो NULL दिखाता है.
आउटपुट का टाइप, इनपुट के टाइप जैसा ही होगा. हालांकि, इन मामलों में ऐसा नहीं होगा:
- अगर किसी
INTEGERकोINTEGERके तौर पर नहीं दिखाया जा सकता, तो उसेDOUBLEमें बदल दिया जाएगा.
Node.js
const result = await db.pipeline() .collection("cities") .aggregate(field("population").average().as("averagePopulation")) .execute();
Web
const result = await execute(db.pipeline() .collection("cities") .aggregate(field("population").average().as("averagePopulation")) );
Swift
let result = try await db.pipeline() .collection("cities") .aggregate([Field("population").average().as("averagePopulation")]) .execute()
Kotlin
val result = db.pipeline() .collection("cities") .aggregate(AggregateFunction.average("population").alias("averagePopulation")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("cities") .aggregate(AggregateFunction.average("population").alias("averagePopulation")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("cities") .aggregate(Field.of("population").average().as_("averagePopulation")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("cities") .aggregate(average("population").as("averagePopulation")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("cities"). Aggregate(firestore.Accumulators( firestore.Average("population").As("averagePopulation"), )). Execute(ctx)
MINIMUM
सिंटैक्स:
minimum(expression: ANY) -> ANY
जानकारी:
हर दस्तावेज़ का आकलन करने पर, यह expression की ऐसी वैल्यू दिखाता है जो न तो NULL हो और न ही मौजूद न हो.
अगर कोई भी वैल्यू NULL या मौजूद नहीं है, तो NULL दिखाया जाता है. इसमें ऐसे मामले भी शामिल हैं जिनमें किसी भी दस्तावेज़ को नहीं चुना गया.
अगर एक जैसी कई वैल्यू हैं, तो उनमें से कोई भी वैल्यू दिखाई जा सकती है. वैल्यू टाइप का क्रम, दस्तावेज़ में दिए गए क्रम के मुताबिक होता है.
Node.js
const result = await db.pipeline() .collection("books") .aggregate(field("price").minimum().as("minimumPrice")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .aggregate(field("price").minimum().as("minimumPrice")) );
Swift
let result = try await db.pipeline() .collection("books") .aggregate([Field("price").minimum().as("minimumPrice")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .aggregate(AggregateFunction.minimum("price").alias("minimumPrice")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .aggregate(AggregateFunction.minimum("price").alias("minimumPrice")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("price").minimum().as_("minimumPrice")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(minimum("price").as("minimumPrice")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Aggregate(firestore.Accumulators( firestore.Minimum("price").As("minimumPrice"), )). Execute(ctx)
MAXIMUM
सिंटैक्स:
maximum(expression: ANY) -> ANY
जानकारी:
हर दस्तावेज़ का आकलन करने पर, expression की ज़्यादा से ज़्यादा वैल्यू दिखाता है. यह वैल्यू, NULL या मौजूद नहीं है के तौर पर नहीं दिखाई जाती.
अगर कोई भी वैल्यू NULL या मौजूद नहीं है, तो NULL दिखाया जाता है. इसमें ऐसे मामले भी शामिल हैं जिनमें किसी भी दस्तावेज़ को नहीं चुना गया.
अगर एक से ज़्यादा वैल्यू सबसे बड़ी हैं, तो उनमें से कोई भी वैल्यू दिखाई जा सकती है. वैल्यू टाइप का क्रम, दस्तावेज़ में दिए गए क्रम के मुताबिक होता है.
Node.js
const result = await db.pipeline() .collection("books") .aggregate(field("price").maximum().as("maximumPrice")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .aggregate(field("price").maximum().as("maximumPrice")) );
Swift
let result = try await db.pipeline() .collection("books") .aggregate([Field("price").maximum().as("maximumPrice")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .aggregate(AggregateFunction.maximum("price").alias("maximumPrice")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .aggregate(AggregateFunction.maximum("price").alias("maximumPrice")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("price").maximum().as_("maximumPrice")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(maximum("price").as("maximumPrice")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Aggregate(firestore.Accumulators( firestore.Maximum("price").As("maximumPrice"), )). Execute(ctx)
पहला
सिंटैक्स:
first(expression: ANY) -> ANY
जानकारी:
यह फ़ंक्शन, पहले दिखाए गए दस्तावेज़ के लिए expression की वैल्यू दिखाता है.
LAST
सिंटैक्स:
last(expression: ANY) -> ANY
जानकारी:
यह रिस्पॉन्स के तौर पर, आखिरी बार दिखाए गए दस्तावेज़ के लिए expression की वैल्यू दिखाता है.
ARRAY_AGG
सिंटैक्स:
array_agg(expression: ANY) -> ARRAY<ANY>
जानकारी:
यह हर दस्तावेज़ का आकलन करने पर, expression की सभी वैल्यू वाली एक श्रेणी दिखाता है.
अगर एक्सप्रेशन से कोई वैल्यू नहीं मिलती है, तो उसे NULL में बदल दिया जाता है.
आउटपुट कलेक्शन में एलिमेंट का क्रम तय नहीं होता है. इसलिए, इस पर भरोसा नहीं किया जाना चाहिए.
ARRAY_AGG_DISTINCT
सिंटैक्स:
array_agg_distinct(expression: ANY) -> ARRAY<ANY>
जानकारी:
यह हर दस्तावेज़ का आकलन करने पर, expression की सभी अलग-अलग वैल्यू वाली एक कैटगरी दिखाता है.
अगर एक्सप्रेशन से कोई वैल्यू नहीं मिलती है, तो उसे NULL में बदल दिया जाता है.
आउटपुट कलेक्शन में एलिमेंट का क्रम तय नहीं होता है. इसलिए, इस पर भरोसा नहीं किया जाना चाहिए.
अंकगणित वाले फ़ंक्शन
Cloud Firestore में मौजूद सभी अंकगणितीय फ़ंक्शन इस तरह काम करते हैं:
- अगर कोई भी इनपुट पैरामीटर
NULLहै, तोNULLके तौर पर नतीजा दिखाता है. - अगर कोई भी आर्ग्युमेंट
NaNहै, तोNaNके तौर पर नतीजा दिखाता है. - ओवरफ़्लो या अंडरफ़्लो होने पर गड़बड़ी जनरेट करता है.
Cloud Firestore, इस क्रम के आधार पर न्यूमेरिक टाइप वाइडनिंग करता है: INT32 < INT64 < FLOAT64 < DECIMAL128. जब कोई अंकगणितीय फ़ंक्शन, अलग-अलग तरह के कई न्यूमेरिक आर्ग्युमेंट लेता है (उदाहरण के लिए, add(5.0D, 6L)), तो छोटे टाइप को ऑपरेंड के बीच मौजूद सबसे बड़े टाइप में बदल दिया जाता है. पिछले उदाहरण में, 6L को 6.0D में बदला गया है. इससे एक्सप्रेशन, FLOAT64 टाइप दिखाता है.
INT64 -> FLOAT64 से इंप्लिसिट कोअर्शन की वजह से, सटीक जानकारी का नुकसान हो सकता है. ऐसा इसलिए, क्योंकि कोअर्शन की गई वैल्यू, अपनी सबसे कम अहम बिट खो सकती है. नतीजे के तौर पर मिलने वाली वैल्यू, IEEE 754 के राउंड-टू-नियरेस्ट मोड का इस्तेमाल करके, ओरिजनल पूर्णांक वैल्यू का राउंड ऑफ़ किया गया वर्शन होगी.
| नाम | ब्यौरा |
ABS
|
number की ऐब्सलूट वैल्यू दिखाता है
|
ADD
|
x + y की वैल्यू दिखाता है
|
SUBTRACT
|
x - y की वैल्यू दिखाता है
|
MULTIPLY
|
x * y की वैल्यू दिखाता है
|
DIVIDE
|
x / y की वैल्यू दिखाता है
|
MOD
|
x / y को भाग देने पर शेषफल दिखाता है
|
CEIL
|
number की सीलिंग वैल्यू दिखाता है
|
FLOOR
|
number का फ़्लोर दिखाता है
|
ROUND
|
number को दशमलव के बाद places अंकों तक पूर्णांकित करता है
|
TRUNC
|
number को दशमलव के बाद places अंकों तक छोटा करता है
|
POW
|
base^exponent की वैल्यू दिखाता है
|
SQRT
|
number का वर्गमूल दिखाता है
|
EXP
|
exponent की घात तक बढ़ाए गए यूलर नंबर को दिखाता है
|
LN
|
number का नैचुरल लॉगारिद्म दिखाता है
|
LOG
|
number का लॉगरिद्म दिखाता है
|
LOG10
|
बेस 10 पर number का लॉगारिद्म दिखाता है
|
RAND
|
एक प्रोसेस के बावजूद रैंडम डेटा निकलने वाला फ़्लोटिंग पॉइंट नंबर दिखाता है |
ABS
सिंटैक्स:
abs[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N) -> N
जानकारी:
यह number की ऐब्सलूट वैल्यू दिखाता है.
- जब फ़ंक्शन
INT32याINT64वैल्यू को ओवरफ़्लो करता है, तो गड़बड़ी का मैसेज दिखाता है.
प्रॉम्प्ट के उदाहरण:
| नंबर | abs(number) |
|---|---|
| 10 | 10 |
| -10 | 10 |
| 10 लाख | 10 लाख |
| -0.0 | 0.0 |
| 10.5 | 10.5 |
| -10.5 | 10.5 |
| -231 | [error] |
| -263 | [error] |
जोड़ें
सिंटैक्स:
add[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](x: N, y: N) -> N
जानकारी:
यह x + y की वैल्यू दिखाता है.
प्रॉम्प्ट के उदाहरण:
| x | साल | add(x, y) |
|---|---|---|
| 20 | 3 | 23 |
| 10.0 | 1 | 11.0 |
| 22.5 | 2.0 | 24.5 |
| INT64.MAX | 1 | [error] |
| INT64.MIN | -1 | [error] |
Node.js
const result = await db.pipeline() .collection("books") .select(field("soldBooks").add(field("unsoldBooks")).as("totalBooks")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("soldBooks").add(field("unsoldBooks")).as("totalBooks")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("soldBooks").add(Field("unsoldBooks")).as("totalBooks")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.add(field("soldBooks"), field("unsoldBooks")).alias("totalBooks")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.add(field("soldBooks"), field("unsoldBooks")).alias("totalBooks")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("soldBooks").add(Field.of("unsoldBooks")).as_("totalBooks")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(add(field("soldBooks"), field("unsoldBooks")).as("totalBooks")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Add(firestore.FieldOf("soldBooks"), firestore.FieldOf("unsoldBooks")).As("totalBooks"), )). Execute(ctx)
SUBTRACT
सिंटैक्स:
subtract[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](x: N, y: N) -> N
जानकारी:
यह x - y की वैल्यू दिखाता है.
प्रॉम्प्ट के उदाहरण:
| x | साल | subtract(x, y) |
|---|---|---|
| 20 | 3 | 17 |
| 10.0 | 1 | 9.0 |
| 22.5 | 2.0 | 20.5 |
| INT64.MAX | -1 | [error] |
| INT64.MIN | 1 | [error] |
Node.js
const storeCredit = 7; const result = await db.pipeline() .collection("books") .select(field("price").subtract(constant(storeCredit)).as("totalCost")) .execute();
Web
const storeCredit = 7; const result = await execute(db.pipeline() .collection("books") .select(field("price").subtract(constant(storeCredit)).as("totalCost")) );
Swift
let storeCredit = 7 let result = try await db.pipeline() .collection("books") .select([Field("price").subtract(Constant(storeCredit)).as("totalCost")]) .execute()
Kotlin
val storeCredit = 7 val result = db.pipeline() .collection("books") .select(Expression.subtract(field("price"), storeCredit).alias("totalCost")) .execute()
Java
int storeCredit = 7; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.subtract(field("price"), storeCredit).alias("totalCost")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field store_credit = 7 result = ( client.pipeline() .collection("books") .select(Field.of("price").subtract(store_credit).as_("totalCost")) .execute() )
Java
int storeCredit = 7; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(subtract(field("price"), storeCredit).as("totalCost")) .execute() .get();
जाएं
storeCredit := 7 snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Subtract(firestore.FieldOf("price"), storeCredit).As("totalCost"), )). Execute(ctx)
MULTIPLY
सिंटैक्स:
multiply[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](x: N, y: N) -> N
जानकारी:
यह x * y की वैल्यू दिखाता है.
प्रॉम्प्ट के उदाहरण:
| x | साल | multiply(x, y) |
|---|---|---|
| 20 | 3 | 60 |
| 10.0 | 1 | 10.0 |
| 22.5 | 2.0 | 45.0 |
| INT64.MAX | 2 | [error] |
| INT64.MIN | 2 | [error] |
| FLOAT64.MAX | FLOAT64.MAX | +inf |
Node.js
const result = await db.pipeline() .collection("books") .select(field("price").multiply(field("soldBooks")).as("revenue")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("price").multiply(field("soldBooks")).as("revenue")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("price").multiply(Field("soldBooks")).as("revenue")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.multiply(field("price"), field("soldBooks")).alias("revenue")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.multiply(field("price"), field("soldBooks")).alias("revenue")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("price").multiply(Field.of("soldBooks")).as_("revenue")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(multiply(field("price"), field("soldBooks")).as("revenue")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Multiply(firestore.FieldOf("price"), firestore.FieldOf("soldBooks")).As("revenue"), )). Execute(ctx)
DIVIDE
सिंटैक्स:
divide[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](x: N, y: N) -> N
जानकारी:
यह x / y की वैल्यू दिखाता है. पूर्णांक विभाजन को छोटा किया गया है.
प्रॉम्प्ट के उदाहरण:
| x | साल | divide(x, y) |
|---|---|---|
| 20 | 3 | 6 |
| 10.0 | 3 | 3.333... |
| 22.5 | 2 | 11.25 |
| 10 | 0 | [error] |
| 1.0 | 0.0 | +inf |
| -1.0 | 0.0 | -inf |
| 0.0 | 0.0 | NaN |
+inf |
+inf |
NaN |
Node.js
const result = await db.pipeline() .collection("books") .select(field("ratings").divide(field("soldBooks")).as("reviewRate")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("ratings").divide(field("soldBooks")).as("reviewRate")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("ratings").divide(Field("soldBooks")).as("reviewRate")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.divide(field("ratings"), field("soldBooks")).alias("reviewRate")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.divide(field("ratings"), field("soldBooks")).alias("reviewRate")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("ratings").divide(Field.of("soldBooks")).as_("reviewRate")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(divide(field("ratings"), field("soldBooks")).as("reviewRate")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Divide(firestore.FieldOf("ratings"), firestore.FieldOf("soldBooks")).As("reviewRate"), )). Execute(ctx)
MOD
सिंटैक्स:
mod[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](x: N, y: N) -> N
जानकारी:
x / y का शेषफल दिखाता है.
- पूर्णांक टाइप (
INT64) के लिए,yके शून्य होने परerrorदिखाता है. - फ़्लोट टाइप (
FLOAT64) के लिए,yके शून्य होने परNaNदिखाता है.
प्रॉम्प्ट के उदाहरण:
| x | साल | mod(x, y) |
|---|---|---|
| 20 | 3 | 2 |
| -10 | 3 | -1 |
| 10 | -3 | 1 |
| -10 | -3 | -1 |
| 10 | 1 | 0 |
| 22.5 | 2 | 0.5 |
| 22.5 | 0.0 | NaN |
| 25 | 0 | [error] |
Node.js
const displayCapacity = 1000; const result = await db.pipeline() .collection("books") .select(field("unsoldBooks").mod(constant(displayCapacity)).as("warehousedBooks")) .execute();
Web
const displayCapacity = 1000; const result = await execute(db.pipeline() .collection("books") .select(field("unsoldBooks").mod(constant(displayCapacity)).as("warehousedBooks")) );
Swift
let displayCapacity = 1000 let result = try await db.pipeline() .collection("books") .select([Field("unsoldBooks").mod(Constant(displayCapacity)).as("warehousedBooks")]) .execute()
Kotlin
val displayCapacity = 1000 val result = db.pipeline() .collection("books") .select(Expression.mod(field("unsoldBooks"), displayCapacity).alias("warehousedBooks")) .execute()
Java
int displayCapacity = 1000; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.mod(field("unsoldBooks"), displayCapacity).alias("warehousedBooks")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field display_capacity = 1000 result = ( client.pipeline() .collection("books") .select(Field.of("unsoldBooks").mod(display_capacity).as_("warehousedBooks")) .execute() )
Java
int displayCapacity = 1000; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(mod(field("unsoldBooks"), displayCapacity).as("warehousedBooks")) .execute() .get();
जाएं
displayCapacity := 1000 snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Mod(firestore.FieldOf("unsoldBooks"), displayCapacity).As("warehousedBooks"), )). Execute(ctx)
CEIL
सिंटैक्स:
ceil[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N) -> N
जानकारी:
यह फ़ंक्शन, सबसे छोटी ऐसी पूर्णांक वैल्यू दिखाता है जो number से कम नहीं है.
प्रॉम्प्ट के उदाहरण:
| नंबर | ceil(number) |
|---|---|
| 20 | 20 |
| 10 | 10 |
| 0 | 0 |
| 24L | 24L |
| -0.4 | -0.0 |
| 0.4 | 1.0 |
| 22.5 | 23.0 |
NaN |
NaN |
+inf |
+inf |
-inf |
-inf |
Node.js
const booksPerShelf = 100; const result = await db.pipeline() .collection("books") .select( field("unsoldBooks").divide(constant(booksPerShelf)).ceil().as("requiredShelves") ) .execute();
Web
const booksPerShelf = 100; const result = await execute(db.pipeline() .collection("books") .select( field("unsoldBooks").divide(constant(booksPerShelf)).ceil().as("requiredShelves") ) );
Swift
let booksPerShelf = 100 let result = try await db.pipeline() .collection("books") .select([ Field("unsoldBooks").divide(Constant(booksPerShelf)).ceil().as("requiredShelves") ]) .execute()
Kotlin
val booksPerShelf = 100 val result = db.pipeline() .collection("books") .select( Expression.divide(field("unsoldBooks"), booksPerShelf).ceil().alias("requiredShelves") ) .execute()
Java
int booksPerShelf = 100; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( Expression.divide(field("unsoldBooks"), booksPerShelf).ceil().alias("requiredShelves") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field books_per_shelf = 100 result = ( client.pipeline() .collection("books") .select( Field.of("unsoldBooks") .divide(books_per_shelf) .ceil() .as_("requiredShelves") ) .execute() )
Java
int booksPerShelf = 100; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(ceil(divide(field("unsoldBooks"), booksPerShelf)).as("requiredShelves")) .execute() .get();
जाएं
booksPerShelf := 100 snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Ceil(firestore.Divide(firestore.FieldOf("unsoldBooks"), booksPerShelf)).As("requiredShelves"), )). Execute(ctx)
FLOOR
सिंटैक्स:
floor[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N) -> N
जानकारी:
सबसे बड़ी पूरी संख्या दिखाता है, जो number से ज़्यादा नहीं है.
प्रॉम्प्ट के उदाहरण:
| नंबर | floor(number) |
|---|---|
| 20 | 20 |
| 10 | 10 |
| 0 | 0 |
| 2147483648 | 2147483648 |
| -0.4 | -1.0 |
| 0.4 | 0.0 |
| 22.5 | 22.0 |
NaN |
NaN |
+inf |
+inf |
-inf |
-inf |
Node.js
const result = await db.pipeline() .collection("books") .addFields( field("wordCount").divide(field("pages")).floor().as("wordsPerPage") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .addFields( field("wordCount").divide(field("pages")).floor().as("wordsPerPage") ) );
Swift
let result = try await db.pipeline() .collection("books") .addFields([ Field("wordCount").divide(Field("pages")).floor().as("wordsPerPage") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .addFields( Expression.divide(field("wordCount"), field("pages")).floor().alias("wordsPerPage") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .addFields( Expression.divide(field("wordCount"), field("pages")).floor().alias("wordsPerPage") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .add_fields( Field.of("wordCount").divide(Field.of("pages")).floor().as_("wordsPerPage") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .addFields(floor(divide(field("wordCount"), field("pages"))).as("wordsPerPage")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). AddFields(firestore.Selectables( firestore.Floor(firestore.Divide(firestore.FieldOf("wordCount"), firestore.FieldOf("pages"))).As("wordsPerPage"), )). Execute(ctx)
ROUND
सिंटैक्स:
round[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N) -> N
round[N <: INT32 | INT64 | FLOAT64 | DECIMAL128](number: N, places: INT64) -> N
जानकारी:
number को places अंकों तक राउंड ऑफ़ करता है. अगर places पॉज़िटिव है, तो यह दशमलव बिंदु के दाईं ओर मौजूद अंकों को राउंड करता है. अगर यह नेगेटिव है, तो दशमलव बिंदु के बाईं ओर मौजूद अंकों को राउंड करता है.
- अगर सिर्फ़
numberदिया गया है, तो यह सबसे नज़दीकी पूरी वैल्यू में बदल जाता है. - यह फ़ंक्शन, आधे मामलों में शून्य से दूर की संख्या को राउंड करता है.
- अगर नेगेटिव
placesवैल्यू के साथ राउंड करने पर ओवरफ़्लो होता है, तोerrorदिखता है.
प्रॉम्प्ट के उदाहरण:
| नंबर | स्थान | round(number, places) |
|---|---|---|
| 15.5 | 0 | 16.0 |
| -15.5 | 0 | -16.0 |
| 15 | 1 | 15 |
| 15 | 0 | 15 |
| 15 | -1 | 20 |
| 15 | -2 | 0 |
| 15.48924 | 1 | 15.5 |
| 231-1 | -1 | [error] |
| 263-1L | -1 | [error] |
Node.js
const result = await db.pipeline() .collection("books") .select(field("soldBooks").multiply(field("price")).round().as("partialRevenue")) .aggregate(field("partialRevenue").sum().as("totalRevenue")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("soldBooks").multiply(field("price")).round().as("partialRevenue")) .aggregate(field("partialRevenue").sum().as("totalRevenue")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("soldBooks").multiply(Field("price")).round().as("partialRevenue")]) .aggregate([Field("partialRevenue").sum().as("totalRevenue")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(Expression.multiply(field("soldBooks"), field("price")).round().alias("partialRevenue")) .aggregate(AggregateFunction.sum("partialRevenue").alias("totalRevenue")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(Expression.multiply(field("soldBooks"), field("price")).round().alias("partialRevenue")) .aggregate(AggregateFunction.sum("partialRevenue").alias("totalRevenue")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("soldBooks") .multiply(Field.of("price")) .round() .as_("partialRevenue") ) .aggregate(Field.of("partialRevenue").sum().as_("totalRevenue")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(round(multiply(field("soldBooks"), field("price"))).as("partialRevenue")) .aggregate(sum("partialRevenue").as("totalRevenue")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Round(firestore.Multiply(firestore.FieldOf("soldBooks"), firestore.FieldOf("price"))).As("partialRevenue"), )). Aggregate(firestore.Accumulators( firestore.Sum("partialRevenue").As("totalRevenue"), )). Execute(ctx)
TRUNC
सिंटैक्स:
trunc[N <: Number](number: N) -> N
trunc[N <: Number](number: N, places: INT64) -> N
जानकारी:
यह फ़ंक्शन, number को दशमलव के बाद places अंकों तक छोटा करता है. अगर places पॉज़िटिव है, तो दशमलव बिंदु के दाईं ओर से अंकों को काटता है. अगर यह नेगेटिव है, तो दशमलव बिंदु के बाईं ओर से अंकों को काटता है.
- अगर सिर्फ़
numberदिया गया है, तो शून्य की ओर सबसे नज़दीकी पूरी वैल्यू को छोटा कर देता है. - अगर ट्रंकेट करने पर ओवरफ़्लो होता है, तो
errorदिखता है.
प्रॉम्प्ट के उदाहरण:
| नंबर | स्थान | trunc(number, places) |
|---|---|---|
| 15.5 | 0 | 15.0 |
| -15.5 | 0 | -15.0 |
| 15 | 1 | 15 |
| 15 | 0 | 15 |
| 15 | -1 | 10 |
| 15 | -2 | 0 |
| 15.48924 | 1 | 15.4 |
| -15.48924 | 2 | -15.48 |
POW
सिंटैक्स:
pow(base: FLOAT64, exponent: FLOAT64) -> FLOAT64
जानकारी:
यह फ़ंक्शन, base की घात exponent की वैल्यू दिखाता है.
अगर
base <= 0औरexponentनेगेटिव है, तो गड़बड़ी का मैसेज दिखता है.किसी भी
exponent(इसमेंNaNशामिल है) के लिए,pow(1, exponent)की वैल्यू 1 होती है.किसी भी
base(इसमेंNaNशामिल है) के लिए,pow(base, 0)की वैल्यू 1 है.
प्रॉम्प्ट के उदाहरण:
| बेस | घातांक | pow(base, exponent) |
|---|---|---|
| 2 | 3 | 8.0 |
| 2 | -3 | 0.125 |
+inf |
0 | 1.0 |
| 1 | +inf |
1.0 |
NaN |
0 | 1.0 |
| 1 | NaN |
1.0 |
NaN |
Numeric |
NaN |
Numeric |
NaN |
NaN |
| -1 | 0.5 | [error] |
| 0 | -1 | [error] |
Node.js
const googleplex = { latitude: 37.4221, longitude: 122.0853 }; const result = await db.pipeline() .collection("cities") .addFields( field("lat").subtract(constant(googleplex.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), field("lng").subtract(constant(googleplex.longitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ) .execute();
Web
const googleplex = { latitude: 37.4221, longitude: 122.0853 }; const result = await execute(db.pipeline() .collection("cities") .addFields( field("lat").subtract(constant(googleplex.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), field("lng").subtract(constant(googleplex.longitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ) );
Swift
let googleplex = CLLocation(latitude: 37.4221, longitude: 122.0853) let result = try await db.pipeline() .collection("cities") .addFields([ Field("lat").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), Field("lng").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ]) .select([ Field("latitudeDifference").add(Field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ]) .execute()
Kotlin
val googleplex = GeoPoint(37.4221, -122.0853) val result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.latitude) .multiply(111) // km per degree .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.longitude) .multiply(111) // km per degree .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute()
Java
GeoPoint googleplex = new GeoPoint(37.4221, -122.0853); Task<Pipeline.Snapshot> result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.getLatitude()) .multiply(111 /* km per degree */) .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.getLongitude()) .multiply(111 /* km per degree */) .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field googleplexLat = 37.4221 googleplexLng = -122.0853 result = ( client.pipeline() .collection("cities") .add_fields( Field.of("lat") .subtract(googleplexLat) .multiply(111) # km per degree .pow(2) .as_("latitudeDifference"), Field.of("lng") .subtract(googleplexLng) .multiply(111) # km per degree .pow(2) .as_("longitudeDifference"), ) .select( Field.of("latitudeDifference") .add(Field.of("longitudeDifference")) .sqrt() # Inaccurate for large distances or close to poles .as_("approximateDistanceToGoogle") ) .execute() )
Java
double googleplexLat = 37.4221; double googleplexLng = -122.0853; Pipeline.Snapshot result = firestore .pipeline() .collection("cities") .addFields( pow(multiply(subtract(field("lat"), googleplexLat), 111), 2) .as("latitudeDifference"), pow(multiply(subtract(field("lng"), googleplexLng), 111), 2) .as("longitudeDifference")) .select( sqrt(add(field("latitudeDifference"), field("longitudeDifference"))) // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle")) .execute() .get();
जाएं
googleplexLat := 37.4221 googleplexLng := -122.0853 snapshot := client.Pipeline(). Collection("cities"). AddFields(firestore.Selectables( firestore.Pow(firestore.Multiply(firestore.Subtract(firestore.FieldOf("lat"), googleplexLat), 111), 2).As("latitudeDifference"), firestore.Pow(firestore.Multiply(firestore.Subtract(firestore.FieldOf("lng"), googleplexLng), 111), 2).As("longitudeDifference"), )). Select(firestore.Fields( firestore.Sqrt(firestore.Add(firestore.FieldOf("latitudeDifference"), firestore.FieldOf("longitudeDifference"))). // Inaccurate for large distances or close to poles As("approximateDistanceToGoogle"), )). Execute(ctx)
SQRT
सिंटैक्स:
sqrt[N <: FLOAT64 | DECIMAL128](number: N) -> N
जानकारी:
number का वर्गमूल दिखाता है.
- अगर
numberनेगेटिव है, तोerrorदिखाता है.
प्रॉम्प्ट के उदाहरण:
| नंबर | sqrt(number) |
|---|---|
| 25 | 5.0 |
| 12.002 | 3.464... |
| 0.0 | 0.0 |
NaN |
NaN |
+inf |
+inf |
-inf |
[error] |
x < 0 |
[error] |
Node.js
const googleplex = { latitude: 37.4221, longitude: 122.0853 }; const result = await db.pipeline() .collection("cities") .addFields( field("lat").subtract(constant(googleplex.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), field("lng").subtract(constant(googleplex.longitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ) .execute();
Web
const googleplex = { latitude: 37.4221, longitude: 122.0853 }; const result = await execute(db.pipeline() .collection("cities") .addFields( field("lat").subtract(constant(googleplex.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), field("lng").subtract(constant(googleplex.longitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ) );
Swift
let googleplex = CLLocation(latitude: 37.4221, longitude: 122.0853) let result = try await db.pipeline() .collection("cities") .addFields([ Field("lat").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("latitudeDifference"), Field("lng").subtract(Constant(googleplex.coordinate.latitude)) .multiply(111 /* km per degree */) .pow(2) .as("longitudeDifference") ]) .select([ Field("latitudeDifference").add(Field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle") ]) .execute()
Kotlin
val googleplex = GeoPoint(37.4221, -122.0853) val result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.latitude) .multiply(111) // km per degree .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.longitude) .multiply(111) // km per degree .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute()
Java
GeoPoint googleplex = new GeoPoint(37.4221, -122.0853); Task<Pipeline.Snapshot> result = db.pipeline() .collection("cities") .addFields( field("lat").subtract(googleplex.getLatitude()) .multiply(111 /* km per degree */) .pow(2) .alias("latitudeDifference"), field("lng").subtract(googleplex.getLongitude()) .multiply(111 /* km per degree */) .pow(2) .alias("longitudeDifference") ) .select( field("latitudeDifference").add(field("longitudeDifference")).sqrt() // Inaccurate for large distances or close to poles .alias("approximateDistanceToGoogle") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field googleplexLat = 37.4221 googleplexLng = -122.0853 result = ( client.pipeline() .collection("cities") .add_fields( Field.of("lat") .subtract(googleplexLat) .multiply(111) # km per degree .pow(2) .as_("latitudeDifference"), Field.of("lng") .subtract(googleplexLng) .multiply(111) # km per degree .pow(2) .as_("longitudeDifference"), ) .select( Field.of("latitudeDifference") .add(Field.of("longitudeDifference")) .sqrt() # Inaccurate for large distances or close to poles .as_("approximateDistanceToGoogle") ) .execute() )
Java
double googleplexLat = 37.4221; double googleplexLng = -122.0853; Pipeline.Snapshot result = firestore .pipeline() .collection("cities") .addFields( pow(multiply(subtract(field("lat"), googleplexLat), 111), 2) .as("latitudeDifference"), pow(multiply(subtract(field("lng"), googleplexLng), 111), 2) .as("longitudeDifference")) .select( sqrt(add(field("latitudeDifference"), field("longitudeDifference"))) // Inaccurate for large distances or close to poles .as("approximateDistanceToGoogle")) .execute() .get();
जाएं
googleplexLat := 37.4221 googleplexLng := -122.0853 snapshot := client.Pipeline(). Collection("cities"). AddFields(firestore.Selectables( firestore.Pow(firestore.Multiply(firestore.Subtract(firestore.FieldOf("lat"), googleplexLat), 111), 2).As("latitudeDifference"), firestore.Pow(firestore.Multiply(firestore.Subtract(firestore.FieldOf("lng"), googleplexLng), 111), 2).As("longitudeDifference"), )). Select(firestore.Fields( firestore.Sqrt(firestore.Add(firestore.FieldOf("latitudeDifference"), firestore.FieldOf("longitudeDifference"))). // Inaccurate for large distances or close to poles As("approximateDistanceToGoogle"), )). Execute(ctx)
EXP
सिंटैक्स:
exp(exponent: FLOAT64) -> FLOAT64
जानकारी:
यह फ़ंक्शन, यूलर नंबर की वैल्यू को exponent की घात के साथ दिखाता है. इसे नैचुरल एक्सपोनेंशियल फ़ंक्शन भी कहा जाता है.
प्रॉम्प्ट के उदाहरण:
| घातांक | exp(exponent) |
|---|---|
| 0.0 | 1.0 |
| 10 | e^10 (FLOAT64) |
NaN |
NaN |
+inf |
+inf |
-inf |
0 |
Node.js
const result = await db.pipeline() .collection("books") .select(field("rating").exp().as("expRating")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").exp().as("expRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").exp().as("expRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").exp().alias("expRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").exp().alias("expRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").exp().as_("expRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(exp(field("rating")).as("expRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Exp(firestore.FieldOf("rating")).As("expRating"), )). Execute(ctx)
LN
सिंटैक्स:
ln(number: FLOAT64) -> FLOAT64
जानकारी:
number का नैचुरल लॉगारिद्म दिखाता है. यह फ़ंक्शन log(number) के बराबर है.
प्रॉम्प्ट के उदाहरण:
| नंबर | ln(number) |
|---|---|
| 1 | 0.0 |
| 2L | 0.693... |
| 1.0 | 0.0 |
e (FLOAT64) |
1.0 |
NaN |
NaN |
-inf |
NaN |
+inf |
+inf |
x <= 0 |
[error] |
Node.js
const result = await db.pipeline() .collection("books") .select(field("rating").ln().as("lnRating")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").ln().as("lnRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").ln().as("lnRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").ln().alias("lnRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").ln().alias("lnRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").ln().as_("lnRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(ln(field("rating")).as("lnRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Ln(firestore.FieldOf("rating")).As("lnRating"), )). Execute(ctx)
LOG
सिंटैक्स:
log(number: FLOAT64, base: FLOAT64) -> FLOAT64
log(number: FLOAT64) -> FLOAT64
जानकारी:
यह फ़ंक्शन, number से base का लॉगारिद्म दिखाता है.
- अगर सिर्फ़
numberदिया गया है, तोbaseको बेस मानकरnumberका लॉगारिद्म दिखाता है (ln(number)का समानार्थी).
प्रॉम्प्ट के उदाहरण:
| नंबर | बेस | log(number, base) |
|---|---|---|
| 100 | 10 | 2.0 |
NaN |
Numeric |
NaN |
Numeric |
NaN |
NaN |
-inf |
Numeric |
NaN |
Numeric. |
+inf |
NaN |
number <= 0 |
Numeric |
[error] |
Numeric |
base <= 0 |
[error] |
Numeric |
1.0 | [error] |
LOG10
सिंटैक्स:
log10(x: FLOAT64) -> FLOAT64
जानकारी:
यह फ़ंक्शन, बेस 10 पर number का लॉगारिद्म दिखाता है.
प्रॉम्प्ट के उदाहरण:
| नंबर | log10(number) |
|---|---|
| 100 | 2.0 |
NaN |
NaN |
-inf |
NaN |
+inf |
+inf |
x <= 0 |
[error] |
RAND
सिंटैक्स:
rand() -> FLOAT64
जानकारी:
यह फ़ंक्शन, 0.0 (शामिल है) और 1.0 (शामिल नहीं है) के बीच की कोई फ़्लोटिंग पॉइंट संख्या दिखाता है. यह संख्या, एक प्रोसेस के बावजूद रैंडम डेटा निकलने के तरीके से चुनी जाती है.
अरे फ़ंक्शन
| नाम | ब्यौरा |
ARRAY
|
यह एक ARRAY दिखाता है, जिसमें हर इनपुट आर्ग्युमेंट के लिए एक एलिमेंट होता है
|
ARRAY_CONCAT
|
एक से ज़्यादा ऐरे को एक ARRAY में जोड़ता है
|
ARRAY_CONTAINS
|
अगर दिए गए ARRAY में कोई खास वैल्यू मौजूद है, तो TRUE दिखाता है
|
ARRAY_CONTAINS_ALL
|
अगर ARRAY में सभी वैल्यू मौजूद हैं, तो TRUE दिखाता है
|
ARRAY_CONTAINS_ANY
|
अगर ARRAY में कोई भी वैल्यू मौजूद है, तो TRUE दिखाता है
|
ARRAY_FILTER
|
यह ARRAY से उन एलिमेंट को फ़िल्टर करता है जो प्रेडिकेट को पूरा नहीं करते
|
ARRAY_FIRST
|
ARRAY में मौजूद पहला एलिमेंट दिखाता है
|
ARRAY_FIRST_N
|
ARRAY में मौजूद पहले n एलिमेंट दिखाता है
|
ARRAY_GET
|
ARRAY में दिए गए इंडेक्स पर मौजूद एलिमेंट दिखाता है
|
ARRAY_INDEX_OF
|
ARRAY में किसी वैल्यू की पहली एंट्री का इंडेक्स दिखाता है
|
ARRAY_INDEX_OF_ALL
|
ARRAY में किसी वैल्यू के सभी इंडेक्स दिखाता है
|
ARRAY_LENGTH
|
ARRAY में मौजूद एलिमेंट की संख्या दिखाता है
|
ARRAY_LAST
|
यह ARRAY में मौजूद आखिरी एलिमेंट दिखाता है
|
ARRAY_LAST_N
|
ARRAY में आखिरी n एलिमेंट दिखाता है
|
ARRAY_REVERSE
|
ARRAY में मौजूद एलिमेंट के क्रम को उलट देता है
|
ARRAY_SLICE
|
ARRAY का एक हिस्सा दिखाता है
|
ARRAY_TRANSFORM
|
हर एलिमेंट पर एक्सप्रेशन लागू करके, ARRAY में मौजूद एलिमेंट को बदलता है
|
MAXIMUM
|
यह फ़ंक्शन, ARRAY में मौजूद सबसे बड़ी वैल्यू दिखाता है
|
MAXIMUM_N
|
ARRAY में n सबसे बड़ी वैल्यू दिखाता है
|
MINIMUM
|
ARRAY में सबसे छोटी संख्या दिखाता है
|
MINIMUM_N
|
ARRAY में n सबसे छोटी वैल्यू दिखाता है
|
SUM
|
यह फ़ंक्शन, किसी ARRAY में मौजूद सभी NUMERIC वैल्यू का कुल योग दिखाता है.
|
JOIN
|
यह ARRAY में मौजूद एलिमेंट को जोड़कर, STRING वैल्यू के तौर पर दिखाता है.
|
ARRAY
सिंटैक्स:
array(values: ANY...) -> ARRAY
जानकारी:
यह दिए गए एलिमेंट से एक अरे बनाता है.
- अगर कोई आर्ग्युमेंट मौजूद नहीं है, तो उसे नतीजे के तौर पर मिलने वाले कलेक्शन में
NULLसे बदल दिया जाता है.
प्रॉम्प्ट के उदाहरण:
| values | array(values) |
|---|---|
| () | [] |
| (1, 2, 3) | [1, 2, 3] |
| ("a", 1, true) | ["a", 1, true] |
| (1, null) | [1, null] |
| (1, [2, 3]) | [1, [2, 3]] |
ARRAY_CONCAT
सिंटैक्स:
array_concat(arrays: ARRAY...) -> ARRAY
जानकारी:
दो या उससे ज़्यादा ऐरे को एक ARRAY में जोड़ता है.
प्रॉम्प्ट के उदाहरण:
| अरे | array_concat(arrays) |
|---|---|
| ([1, 2], [3, 4]) | [1, 2, 3, 4] |
| (["a", "b"], ["c"]) | ["a", "b", "c"] |
| ([1], [2], [3]) | [1, 2, 3] |
| ([], [1, 2]) | [1, 2] |
Node.js
const result = await db.pipeline() .collection("books") .select(field("genre").arrayConcat([field("subGenre")]).as("allGenres")) .execute();
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayConcat([Field("subGenre")]).as("allGenres")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayConcat(field("subGenre")).alias("allGenres")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayConcat(field("subGenre")).alias("allGenres")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_concat(Field.of("subGenre")).as_("allGenres")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayConcat(field("genre"), field("subGenre")).as("allGenres")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayConcat(firestore.FieldOf("genre"), firestore.FieldOf("subGenre")).As("allGenres"), )). Execute(ctx)
ARRAY_CONTAINS
सिंटैक्स:
array_contains(array: ARRAY, value: ANY) -> BOOLEAN
जानकारी:
अगर array में value मौजूद है, तो TRUE दिखाता है. अगर मौजूद नहीं है, तो FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | value | array_contains(array, value) |
|---|---|---|
| [1, 2, 3] | 2 | सही |
| [[1, 2], [3]] | [1, 2] | सही |
| [1, null] | शून्य | सही |
| "abc" | कोई भी | गड़बड़ी |
Node.js
const result = await db.pipeline() .collection("books") .select(field("genre").arrayContains(constant("mystery")).as("isMystery")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("genre").arrayContains(constant("mystery")).as("isMystery")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayContains(Constant("mystery")).as("isMystery")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayContains("mystery").alias("isMystery")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayContains("mystery").alias("isMystery")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_contains("mystery").as_("isMystery")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayContains(field("genre"), "mystery").as("isMystery")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayContains(firestore.FieldOf("genre"), "mystery").As("isMystery"), )). Execute(ctx)
ARRAY_CONTAINS_ALL
सिंटैक्स:
array_contains_all(array: ARRAY, search_values: ARRAY) -> BOOLEAN
जानकारी:
अगर array में सभी search_values मौजूद हैं, तो TRUE दिखाता है. ऐसा न होने पर, FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | search_values | array_contains_all(array, search_values) |
|---|---|---|
| [1, 2, 3] | [1, 2] | सही |
| [1, 2, 3] | [1, 4] | गलत |
| [1, null] | [अमान्य] | सही |
| [NaN] | [NaN] | सही |
| [] | [] | सही |
| [1, 2, 3] | [] | सही |
Node.js
const result = await db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll([constant("fantasy"), constant("adventure")]) .as("isFantasyAdventure") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll([constant("fantasy"), constant("adventure")]) .as("isFantasyAdventure") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("genre") .arrayContainsAll([Constant("fantasy"), Constant("adventure")]) .as("isFantasyAdventure") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll(listOf("fantasy", "adventure")) .alias("isFantasyAdventure") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAll(Arrays.asList("fantasy", "adventure")) .alias("isFantasyAdventure") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("genre") .array_contains_all(["fantasy", "adventure"]) .as_("isFantasyAdventure") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayContainsAll(field("genre"), Arrays.asList("fantasy", "adventure")) .as("isFantasyAdventure")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayContainsAll(firestore.FieldOf("genre"), []string{"fantasy", "adventure"}).As("isFantasyAdventure"), )). Execute(ctx)
ARRAY_CONTAINS_ANY
सिंटैक्स:
array_contains_any(array: ARRAY, search_values: ARRAY) -> BOOLEAN
जानकारी:
अगर array में कोई भी search_values मिलता है, तो TRUE दिखाता है. ऐसा न होने पर, FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | search_values | array_contains_any(array, search_values) |
|---|---|---|
| [1, 2, 3] | [4, 1] | सही |
| [1, 2, 3] | [4, 5] | गलत |
| [1, 2, null] | [अमान्य] | सही |
Node.js
const result = await db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny([constant("fantasy"), constant("nonfiction")]) .as("isMysteryOrFantasy") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny([constant("fantasy"), constant("nonfiction")]) .as("isMysteryOrFantasy") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("genre") .arrayContainsAny([Constant("fantasy"), Constant("nonfiction")]) .as("isMysteryOrFantasy") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny(listOf("fantasy", "nonfiction")) .alias("isMysteryOrFantasy") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre") .arrayContainsAny(Arrays.asList("fantasy", "nonfiction")) .alias("isMysteryOrFantasy") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("genre") .array_contains_any(["fantasy", "nonfiction"]) .as_("isMysteryOrFantasy") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayContainsAny(field("genre"), Arrays.asList("fantasy", "nonfiction")) .as("isMysteryOrFantasy")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayContainsAny(firestore.FieldOf("genre"), []string{"fantasy", "nonfiction"}).As("isMysteryOrFantasy"), )). Execute(ctx)
ARRAY_FILTER
सिंटैक्स:
array_filter(array: ARRAY, predicate: (ANY) -> BOOLEAN) -> ARRAY
जानकारी:
predicate एक्सप्रेशन का इस्तेमाल करके, array को फ़िल्टर करता है. साथ ही, सिर्फ़ उन एलिमेंट के साथ एक नया कलेक्शन दिखाता है जो प्रेडिकेट को पूरा करते हैं.
arrayमें मौजूद हर एलिमेंट के लिए,predicateका आकलन किया जाता है. अगर यहtrueदिखाता है, तो एलिमेंट को नतीजे में शामिल किया जाता है. अगर यहfalseयाnullदिखाता है, तो एलिमेंट को नतीजे में शामिल नहीं किया जाता.- अगर
predicateकी वैल्यू बूलियन या शून्य नहीं है, तो फ़ंक्शन गड़बड़ी दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | प्रेडिकेट | array_filter(array, predicate) |
|---|---|---|
| [1, 2, 3] | x -> x > 1 | [2, 3] |
| [1, null, 3] | x -> x > 1 | [3] |
| ["a", "b", "c"] | x -> x != "b" | ["a", "c"] |
| [] | x -> true | [] |
ARRAY_GET
सिंटैक्स:
array_get(array: ARRAY, index: INT64) -> ANY
जानकारी:
यह array में 0-आधारित index पर मौजूद एलिमेंट दिखाता है.
- अगर
indexनेगेटिव है, तो कलेक्शन के आखिर से एलिमेंट ऐक्सेस किए जाते हैं. इसमें-1आखिरी एलिमेंट होता है. - अगर
array,ARRAYटाइप का नहीं है औरnullनहीं है, तो गड़बड़ी का मैसेज दिखता है. - अगर
indexतय सीमा से बाहर है, तो फ़ंक्शन कोई वैल्यू नहीं दिखाता. - अगर
index,INT64टाइप का नहीं है, तो फ़ंक्शन एक गड़बड़ी दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | इंडेक्स | array_get(array, index) |
|---|---|---|
| [1, 2, 3] | 0 | 1 |
| [1, 2, 3] | -1 | 3 |
| [1, 2, 3] | 3 | अनुपस्थित |
| [1, 2, 3] | -4 | अनुपस्थित |
| "abc" | 0 | गड़बड़ी |
| शून्य | 0 | शून्य |
Array |
"a" | गड़बड़ी |
Array |
2.0 | गड़बड़ी |
ARRAY_LENGTH
सिंटैक्स:
array_length(array: ARRAY) -> INT64
जानकारी:
array में मौजूद एलिमेंट की संख्या दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | array_length(array) |
|---|---|
| [1, 2, 3] | 3 |
| [] | 0 |
| [1, 1, 1] | 3 |
| [1, null] | 2 |
Node.js
const result = await db.pipeline() .collection("books") .select(field("genre").arrayLength().as("genreCount")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("genre").arrayLength().as("genreCount")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayLength().as("genreCount")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayLength().alias("genreCount")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayLength().alias("genreCount")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_length().as_("genreCount")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayLength(field("genre")).as("genreCount")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayLength(firestore.FieldOf("genre")).As("genreCount"), )). Execute(ctx)
ARRAY_REVERSE
सिंटैक्स:
array_reverse(array: ARRAY) -> ARRAY
जानकारी:
यह दिए गए array को उलट देता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | array_reverse(array) |
|---|---|
| [1, 2, 3] | [3, 2, 1] |
| ["a", "b"] | ["b", "a"] |
| [1, 2, 2, 3] | [3, 2, 2, 1] |
Node.js
const result = await db.pipeline() .collection("books") .select(arrayReverse(field("genre")).as("reversedGenres")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("genre").arrayReverse().as("reversedGenres")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("genre").arrayReverse().as("reversedGenres")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("genre").arrayReverse().alias("reversedGenres")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("genre").arrayReverse().alias("reversedGenres")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_reverse().as_("reversedGenres")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayReverse(field("genre")).as("reversedGenres")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayReverse(firestore.FieldOf("genre")).As("reversedGenres"), )). Execute(ctx)
ARRAY_FIRST
सिंटैक्स:
array_first(array: ARRAY) -> ANY
जानकारी:
array में मौजूद पहला एलिमेंट दिखाता है. यह array_get(array, 0) के बराबर है.
- अगर
arrayखाली है, तो यह फ़ंक्शन कोई वैल्यू नहीं दिखाता.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | array_first(array) |
|---|---|
| [1, 2, 3] | 1 |
| [] | अनुपस्थित |
ARRAY_FIRST_N
सिंटैक्स:
array_first_n(array: ARRAY, n: INT64) -> ARRAY
जानकारी:
array के पहले n एलिमेंट दिखाता है. यह array_slice(array, 0, n) के बराबर है.
- अगर
nनेगेटिव है, तो गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | n | array_first_n(array, n) |
|---|---|---|
| [1, 2, 3, 4, 5] | 3 | [1, 2, 3] |
| [1, 2] | 3 | [1, 2] |
| [1, 2, 3] | 0 | [] |
ARRAY_INDEX_OF
सिंटैक्स:
array_index_of(array: ARRAY, value: ANY) -> INT64
जानकारी:
array में value की पहली एंट्री का 0-आधारित इंडेक्स दिखाता है. value न मिलने पर -1 दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | value | array_index_of(array, value) |
|---|---|---|
| [1, 2, 3, 2] | 2 | 1 |
| [1, 2, 3] | 4 | -1 |
| [1, null, 3] | शून्य | 1 |
ARRAY_INDEX_OF_ALL
सिंटैक्स:
array_index_of_all(array: ARRAY, value: ANY) -> ARRAY<INT64>
जानकारी:
यह फ़ंक्शन, array में value के सभी इंस्टेंस के 0-आधारित इंडेक्स वाला कलेक्शन दिखाता है. value न मिलने पर, [] दिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | value | array_index_of_all(array, value) |
|---|---|---|
| [1, 2, 3, 2] | 2 | [1, 3] |
| [1, 2, 3] | 4 | [] |
| [1, null, 3, null] | शून्य | [1, 3] |
ARRAY_LAST
सिंटैक्स:
array_last(array: ARRAY) -> ANY
जानकारी:
array में मौजूद आखिरी एलिमेंट दिखाता है. यह array_get(array, -1) के बराबर है.
- अगर
arrayखाली है, तो यह फ़ंक्शन कोई वैल्यू नहीं दिखाता.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | array_last(array) |
|---|---|
| [1, 2, 3] | 3 |
| [] | अनुपस्थित |
ARRAY_LAST_N
सिंटैक्स:
array_last_n(array: ARRAY, n: INT64) -> ARRAY
जानकारी:
यह फ़ंक्शन, array के आखिरी n एलिमेंट दिखाता है.
- अगर
nनेगेटिव है, तो गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | n | array_last_n(array, n) |
|---|---|---|
| [1, 2, 3, 4, 5] | 3 | [3, 4, 5] |
| [1, 2] | 3 | [1, 2] |
| [1, 2, 3] | 0 | [] |
ARRAY_SLICE
सिंटैक्स:
array_slice(array: ARRAY, offset: INT64, length: INT64) -> ARRAY
जानकारी:
0 से शुरू होने वाले इंडेक्स offset से शुरू होने वाले array का सबसेट दिखाता है. इसमें length एलिमेंट शामिल होते हैं.
- अगर
offsetनेगेटिव है, तो यह ऐरे के आखिर से शुरू होने वाली पोज़िशन को दिखाता है. इसमें-1आखिरी एलिमेंट होता है. - अगर
length,offsetके बाद कलेक्शन में बचे एलिमेंट की संख्या से ज़्यादा है, तो नतीजा कलेक्शन के आखिर तक बढ़ जाता है. lengthकी वैल्यू शून्य या उससे ज़्यादा होनी चाहिए. ऐसा न होने पर, गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | ऑफ़सेट | लंबाई | array_slice(array, offset, length) |
|---|---|---|---|
| [1, 2, 3, 4, 5] | 1 | 3 | [2, 3, 4] |
| [1, 2, 3, 4, 5] | -2 | 2 | [4, 5] |
| [1, 2, 3] | 1 | 5 | [2, 3] |
| [1, 2, 3] | 3 | 2 | [] |
ARRAY_TRANSFORM
सिंटैक्स:
array_transform(array: ARRAY, expression: (ANY) -> ANY) -> ARRAY
array_transform(array: ARRAY, expression: (ANY, INT64) -> ANY) -> ARRAY
जानकारी:
यह फ़ंक्शन, array में मौजूद हर एलिमेंट पर expression लागू करके, उसे बदलता है. साथ ही, बदले गए एलिमेंट के साथ एक नई कलेक्शन दिखाता है. आउटपुट कलेक्शन का साइज़ हमेशा इनपुट कलेक्शन के साइज़ के बराबर होगा.
expression, यूनरी फ़ंक्शनelement -> resultया बाइनरी फ़ंक्शन(element, index) -> resultहो सकता है.- अगर
expressionयूनरी है, तो इसेarrayके हर एलिमेंट के साथ कॉल किया जाता है. - अगर
expressionबाइनरी है, तो इसेarrayके हर एलिमेंट और उसके 0-आधारित इंडेक्स के साथ कॉल किया जाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | एक्सप्रेशन | array_transform(array, expression) |
|---|---|---|
| [1, 2, 3] | x -> x * 2 | [2, 4, 6] |
| [1, 2, 3] | x -> x + 1 | [2, 3, 4] |
| [10, 20] | (x, i) -> x + i | [10, 21] |
| [] | x -> 1 | [] |
MAXIMUM
सिंटैक्स:
maximum(array: ARRAY) -> ANY
जानकारी:
array में मौजूद सबसे बड़ी वैल्यू दिखाता है.
- तुलना के दौरान,
NULLवैल्यू को अनदेखा कर दिया जाता है. - अगर
arrayखाली है या इसमें सिर्फ़NULLवैल्यू हैं, तोNULLदिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | maximum(array) |
|---|---|
| [1, 5, 2] | 5 |
| [1, null, 5] | 5 |
| ["a", "c", "b"] | "c" |
| [null, null] | शून्य |
| [] | शून्य |
MAXIMUM_N
सिंटैक्स:
maximum_n(array: ARRAY, n: INT64) -> ARRAY
जानकारी:
यह फ़ंक्शन, array में मौजूद n सबसे बड़ी वैल्यू का कलेक्शन, घटते क्रम में दिखाता है.
NULLवैल्यू को अनदेखा कर दिया जाता है.- अगर
nनेगेटिव है, तो गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | n | maximum_n(array, n) |
|---|---|---|
| [1, 5, 2, 4, 3] | 3 | [5, 4, 3] |
| [1, null, 5] | 3 | [5, 1] |
MINIMUM
सिंटैक्स:
minimum(array: ARRAY) -> ANY
जानकारी:
array में सबसे कम वैल्यू दिखाता है.
- तुलना के दौरान,
NULLवैल्यू को अनदेखा कर दिया जाता है. - अगर
arrayखाली है या इसमें सिर्फ़NULLवैल्यू हैं, तोNULLदिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | minimum(array) |
|---|---|
| [1, 5, 2] | 1 |
| [5, null, 1] | 1 |
| ["a", "c", "b"] | "a" |
| [null, null] | शून्य |
| [] | शून्य |
MINIMUM_N
सिंटैक्स:
minimum_n(array: ARRAY, n: INT64) -> ARRAY
जानकारी:
array में मौजूद n सबसे छोटी वैल्यू की श्रेणी को बढ़ते क्रम में दिखाता है.
NULLवैल्यू को अनदेखा कर दिया जाता है.- अगर
nनेगेटिव है, तो गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | n | minimum_n(array, n) |
|---|---|---|
| [1, 5, 2, 4, 3] | 3 | [1, 2, 3] |
| [5, null, 1] | 3 | [1, 5] |
SUM
सिंटैक्स:
sum(array: ARRAY) -> INT64 | FLOAT64
जानकारी:
यह फ़ंक्शन, किसी ARRAY में मौजूद सभी NUMERIC वैल्यू का कुल योग दिखाता है.
- अरे में मौजूद ऐसी वैल्यू को अनदेखा कर दिया जाता है जो संख्या के तौर पर नहीं हैं.
- अगर कलेक्शन में कोई भी संख्या वाली वैल्यू
NaNहै, तो फ़ंक्शनNaNदिखाता है. - रिटर्न टाइप, कलेक्शन में मौजूद सबसे बड़े न्यूमेरिक टाइप से तय होता है:
INT64<FLOAT64. - अगर किसी फ़्लोटिंग पॉइंट वैल्यू को जोड़ने से पहले, 64-बिट इंटिजर ओवरफ़्लो होता है, तो गड़बड़ी का मैसेज दिखता है. अगर फ़्लोटिंग पॉइंट वैल्यू को जोड़ा जाता है, तो ओवरफ़्लो की वजह से +/- इनफ़िनिटी मिलेगी.
- अगर कलेक्शन में कोई भी संख्या वाली वैल्यू नहीं है, तो फ़ंक्शन
NULLदिखाता है.
प्रॉम्प्ट के उदाहरण:
| कलेक्शन | sum(array) |
|---|---|
| [1, 2, 3] | 6L |
| [1L, 2L, 3L] | 6L |
| [2000000000, 2000000000] | 4000000000L |
| [10, 20.5] | 30.5 |
| [1, "a", 2] | 3L |
| [INT64.MAX_VALUE, 1] | गड़बड़ी |
| [INT64.MAX_VALUE, 1, -1.0] | गड़बड़ी |
| [INT64.MAX_VALUE, 1.0] | 9.223372036854776e+18 |
JOIN
सिंटैक्स:
join[T <: STRING | BYTES](array: ARRAY<T>, delimiter: T) -> STRING
join[T <: STRING | BYTES](array: ARRAY<T>, delimiter: T, null_text: T) -> STRING
जानकारी:
यह array में मौजूद एलिमेंट को STRING के तौर पर जोड़कर दिखाता है. array, STRING या BYTES डेटा टाइप का हो सकता है.
array,delimiter, औरnull_textमें मौजूद सभी एलिमेंट एक ही तरह के होने चाहिए. ये सभी एलिमेंट,STRINGयाBYTESहोने चाहिए.- अगर
null_textदिया गया है, तोarrayमें मौजूदNULLकी सभी वैल्यू कोnull_textसे बदल दिया जाता है. - अगर
null_textनहीं दिया गया है, तोarrayमें मौजूदNULLवैल्यू को नतीजे से हटा दिया जाता है.
प्रॉम्प्ट के उदाहरण:
null_text की वैल्यू न देने पर:
| कलेक्शन | डेलिमिटर | join(array, delimiter) |
|---|---|---|
| ["a", "b", "c"] | "," | "a,b,c" |
| ["a", null, "c"] | "," | "a,c" |
| [b'a', b'b', b'c'] | b',' | b'a,b,c' |
| ["a", b'c'] | "," | गड़बड़ी |
| ["a", "c"] | b',' | गड़बड़ी |
| [b'a', b'c'] | "," | गड़बड़ी |
null_text की वैल्यू सबमिट करने पर:
| कलेक्शन | डेलिमिटर | null_text | join(array, delimiter, null_text) |
|---|---|---|---|
| ["a", null, "c"] | "," | "MISSING" | "a,MISSING,c" |
| [b'a', null, b'c'] | b',' | b'NULL' | b'a,NULL,c' |
| [null, "b", null] | "," | "MISSING" | "MISSING,b,MISSING" |
| [b'a', null, null] | b',' | b'NULL' | b'a,NULL,NULL' |
| ["a", null] | "," | b'N' | गड़बड़ी |
| [b'a', null] | b',' | "N" | गड़बड़ी |
तुलना करने वाले फ़ंक्शन
| नाम | ब्यौरा |
EQUAL
|
बराबर होने की तुलना |
GREATER_THAN
|
'इससे ज़्यादा' तुलना |
GREATER_THAN_OR_EQUAL
|
इससे ज़्यादा या इसके बराबर की तुलना |
LESS_THAN
|
तुलना के नतीजों से कम |
LESS_THAN_OR_EQUAL
|
इससे कम या इसके बराबर की तुलना |
NOT_EQUAL
|
'इसके बराबर नहीं है' तुलना |
CMP
|
सामान्य तुलना |
EQUAL
सिंटैक्स:
equal(x: ANY, y: ANY) -> BOOLEAN
प्रॉम्प्ट के उदाहरण:
x |
y |
equal(x, y) |
|---|---|---|
| 1L | 1L | TRUE |
| 1.0 | 1L | TRUE |
| -1.0 | 1L | FALSE |
| NaN | NaN | TRUE |
NULL |
NULL |
TRUE |
NULL |
ABSENT |
FALSE |
जानकारी:
अगर x और y बराबर हैं, तो TRUE दिखाता है. अगर ऐसा नहीं है, तो FALSE दिखाता है.
Node.js
const result = await db.pipeline() .collection("books") .select(field("rating").equal(5).as("hasPerfectRating")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").equal(5).as("hasPerfectRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").equal(5).as("hasPerfectRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").equal(5).alias("hasPerfectRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").equal(5).alias("hasPerfectRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").equal(5).as_("hasPerfectRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(equal(field("rating"), 5).as("hasPerfectRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Equal(firestore.FieldOf("rating"), 5).As("hasPerfectRating"), )). Execute(ctx)
GREATER_THAN
सिंटैक्स:
greater_than(x: ANY, y: ANY) -> BOOLEAN
जानकारी:
अगर x, y से ज़्यादा है, तो TRUE दिखाता है. ऐसा न होने पर, FALSE दिखाता है.
अगर x और y की तुलना नहीं की जा सकती, तो FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
greater_than(x, y) |
|---|---|---|
| 1L | 0.0 | TRUE |
| 1L | 1L | FALSE |
| 1L | 2L | FALSE |
| "foo" | 0L | FALSE |
| 0L | "foo" | FALSE |
| NaN | 0L | FALSE |
| 0L | NaN | FALSE |
NULL |
NULL |
FALSE |
Node.js
const result = await db.pipeline() .collection("books") .select(field("rating").greaterThan(4).as("hasHighRating")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").greaterThan(4).as("hasHighRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").greaterThan(4).as("hasHighRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").greaterThan(4).alias("hasHighRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").greaterThan(4).alias("hasHighRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").greater_than(4).as_("hasHighRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(greaterThan(field("rating"), 4).as("hasHighRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.GreaterThan(firestore.FieldOf("rating"), 4).As("hasHighRating"), )). Execute(ctx)
GREATER_THAN_OR_EQUAL
सिंटैक्स:
greater_than_or_equal(x: ANY, y: ANY) -> BOOLEAN
जानकारी:
अगर x, y से ज़्यादा या इसके बराबर है, तो TRUE दिखाता है. अगर ऐसा नहीं है, तो FALSE दिखाता है.
अगर x और y की तुलना नहीं की जा सकती, तो FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
greater_than_or_equal(x, y) |
|---|---|---|
| 1L | 0.0 | TRUE |
| 1L | 1L | TRUE |
| 1L | 2L | FALSE |
| "foo" | 0L | FALSE |
| 0L | "foo" | FALSE |
| NaN | 0L | FALSE |
| 0L | NaN | FALSE |
NULL |
NULL |
TRUE |
Node.js
const result = await db.pipeline() .collection("books") .select(field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("published").greaterThanOrEqual(1900).alias("publishedIn20thCentury")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("published").greaterThanOrEqual(1900).alias("publishedIn20thCentury")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("published") .greater_than_or_equal(1900) .as_("publishedIn20thCentury") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(greaterThanOrEqual(field("published"), 1900).as("publishedIn20thCentury")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.GreaterThanOrEqual(firestore.FieldOf("published"), 1900).As("publishedIn20thCentury"), )). Execute(ctx)
LESS_THAN
सिंटैक्स:
less_than(x: ANY, y: ANY) -> BOOLEAN
जानकारी:
अगर x, y से कम है, तो TRUE दिखाता है. अगर ऐसा नहीं है, तो FALSE दिखाता है.
अगर x और y की तुलना नहीं की जा सकती, तो FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
less_than(x, y) |
|---|---|---|
| 1L | 0.0 | FALSE |
| 1L | 1L | FALSE |
| 1L | 2L | TRUE |
| "foo" | 0L | FALSE |
| 0L | "foo" | FALSE |
| NaN | 0L | FALSE |
| 0L | NaN | FALSE |
NULL |
NULL |
FALSE |
Node.js
const result = await db.pipeline() .collection("books") .select(field("published").lessThan(1923).as("isPublicDomainProbably")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("published").lessThan(1923).as("isPublicDomainProbably")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("published").lessThan(1923).as("isPublicDomainProbably")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("published").lessThan(1923).alias("isPublicDomainProbably")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("published").lessThan(1923).alias("isPublicDomainProbably")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("published").less_than(1923).as_("isPublicDomainProbably")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(lessThan(field("published"), 1923).as("isPublicDomainProbably")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.LessThan(firestore.FieldOf("published"), 1923).As("isPublicDomainProbably"), )). Execute(ctx)
LESS_THAN_OR_EQUAL
सिंटैक्स:
less_than_or_equal(x: ANY, y: ANY) -> BOOLEAN
जानकारी:
अगर x, y से कम या इसके बराबर है, तो TRUE दिखाता है. अगर ऐसा नहीं है, तो FALSE दिखाता है.
अगर x और y की तुलना नहीं की जा सकती, तो FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
less_than(x, y) |
|---|---|---|
| 1L | 0.0 | FALSE |
| 1L | 1L | TRUE |
| 1L | 2L | TRUE |
| "foo" | 0L | FALSE |
| 0L | "foo" | FALSE |
| NaN | 0L | FALSE |
| 0L | NaN | FALSE |
NULL |
NULL |
TRUE |
Node.js
const result = await db.pipeline() .collection("books") .select(field("rating").lessThanOrEqual(2).as("hasBadRating")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("rating").lessThanOrEqual(2).as("hasBadRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").lessThanOrEqual(2).as("hasBadRating")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("rating").lessThanOrEqual(2).alias("hasBadRating")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").lessThanOrEqual(2).alias("hasBadRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").less_than_or_equal(2).as_("hasBadRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(lessThanOrEqual(field("rating"), 2).as("hasBadRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.LessThanOrEqual(firestore.FieldOf("rating"), 2).As("hasBadRating"), )). Execute(ctx)
NOT_EQUAL
सिंटैक्स:
not_equal(x: ANY, y: ANY) -> BOOLEAN
जानकारी:
अगर x, y के बराबर नहीं है, तो TRUE दिखाता है. अगर बराबर है, तो FALSE दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
not_equal(x, y) |
|---|---|---|
| 1L | 1L | FALSE |
| 1.0 | 1L | FALSE |
| -1.0 | 1L | TRUE |
| NaN | 0L | TRUE |
| NaN | NaN | FALSE |
NULL |
NULL |
FALSE |
NULL |
ABSENT |
TRUE |
Node.js
const result = await db.pipeline() .collection("books") .select(field("title").notEqual("1984").as("not1984")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("title").notEqual("1984").as("not1984")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("title").notEqual("1984").as("not1984")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("title").notEqual("1984").alias("not1984")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("title").notEqual("1984").alias("not1984")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").not_equal("1984").as_("not1984")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(notEqual(field("title"), "1984").as("not1984")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.NotEqual(firestore.FieldOf("title"), "1984").As("not1984"), )). Execute(ctx)
CMP
सिंटैक्स:
cmp(x: ANY, y: ANY) -> Int64
जानकारी:
x और y की तुलना करता है और यह वैल्यू दिखाता है:
1L, अगरx,yसे ज़्यादा है.-1L, अगरx,yसे कम है.- अगर ऐसा नहीं है, तो
0Lका इस्तेमाल करें.
तुलना करने वाले अन्य फ़ंक्शन के उलट, cmp(...) फ़ंक्शन सभी टाइप के साथ काम करता है. यह sort(...) स्टेज में इस्तेमाल किए गए क्रम का ही पालन करता है. वैल्यू को अलग-अलग टाइप के हिसाब से कैसे क्रम में लगाया जाता है, यह जानने के लिए वैल्यू टाइप का क्रम देखें.
प्रॉम्प्ट के उदाहरण:
x |
y |
cmp(x, y) |
|---|---|---|
| 1L | 1L | 0L |
| 1.0 | 1L | 0L |
| -1.0 | 1L | -1L |
| 42.5D | "foo" | -1L |
NULL |
NULL |
0L |
NULL |
ABSENT |
0L |
डीबग करने वाले फ़ंक्शन
| नाम | ब्यौरा |
EXISTS
|
अगर वैल्यू मौजूद है, तो TRUE दिखाता है
|
IS_ABSENT
|
अगर वैल्यू मौजूद नहीं है, तो TRUE दिखाता है
|
IF_ABSENT
|
अगर वैल्यू मौजूद नहीं है, तो उसे एक्सप्रेशन से बदलता है |
IS_ERROR
|
यह नोड, गड़बड़ियों को पकड़ता है और उनकी जांच करता है. यह गड़बड़ियां, इसके अंदर मौजूद एक्सप्रेशन से जनरेट होती हैं |
IF_ERROR
|
अगर किसी वैल्यू की वजह से गड़बड़ी हुई है, तो उसे किसी एक्सप्रेशन से बदलता है |
ERROR
|
यह फ़ंक्शन, आकलन को खत्म करता है और दिए गए मैसेज के साथ गड़बड़ी दिखाता है |
EXISTS
सिंटैक्स:
exists(value: ANY) -> BOOLEAN
जानकारी:
अगर value की वैल्यू मौजूद है, तो TRUE दिखाता है.
प्रॉम्प्ट के उदाहरण:
value |
exists(value) |
|---|---|
| 0L | TRUE |
| "foo" | TRUE |
NULL |
TRUE |
ABSENT |
FALSE |
Node.js
const result = await db.pipeline() .collection("books") .select(field("rating").exists().as("hasRating")) .execute();
Web
उदाहरण:
const result = await execute(db.pipeline() .collection("books") .select(field("rating").exists().as("hasRating")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("rating").exists().as("hasRating")]) .execute()
Kotlin
उदाहरण:
val result = db.pipeline() .collection("books") .select(field("rating").exists().alias("hasRating")) .execute()
Java
उदाहरण:
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("rating").exists().alias("hasRating")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").exists().as_("hasRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(exists(field("rating")).as("hasRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.FieldExists(firestore.FieldOf("rating")).As("hasRating"), )). Execute(ctx)
IS_ABSENT
सिंटैक्स:
is_absent(value: ANY) -> BOOLEAN
जानकारी:
अगर value मौजूद नहीं है, तो TRUE दिखाता है. अगर मौजूद है, तो FALSE दिखाता है. ऐब्सेंट वैल्यू,
वे वैल्यू होती हैं जो इनपुट में मौजूद नहीं होती हैं. जैसे, दस्तावेज़ का कोई फ़ील्ड मौजूद न होना.
प्रॉम्प्ट के उदाहरण:
value |
is_absent(value) |
|---|---|
| 0L | FALSE |
| "foo" | FALSE |
NULL |
FALSE |
ABSENT |
TRUE |
IF_ABSENT
सिंटैक्स:
if_absent(value: ANY, replacement: ANY) -> ANY
जानकारी:
अगर value की वैल्यू मौजूद नहीं है, तो replacement का आकलन करता है और उसे दिखाता है. ऐसा न होने पर, value दिखाता है.
प्रॉम्प्ट के उदाहरण:
value |
replacement |
if_absent(value, replacement) |
|---|---|---|
| 5 लाख | 0L | 5 लाख |
NULL |
0L | NULL |
ABSENT |
0L | 0L |
IS_ERROR
सिंटैक्स:
is_error(try: ANY) -> BOOLEAN
जानकारी:
अगर try का आकलन करते समय कोई गड़बड़ी होती है, तो TRUE दिखाता है. अगर ऐसा नहीं है, तो रिस्पॉन्स के तौर पर FALSE मिलता है.
IF_ERROR
सिंटैक्स:
if_error(try: ANY, catch: ANY) -> ANY
जानकारी:
अगर try का आकलन करते समय कोई गड़बड़ी होती है, तो replacement का आकलन करके उसे दिखाता है. ऐसा न होने पर, try की रिज़ॉल्व की गई वैल्यू दिखाता है.
गड़बड़ी
सिंटैक्स:
error(message: STRING) -> ANY
जानकारी:
error फ़ंक्शन को एक्ज़ीक्यूट करने पर, पाइपलाइन को एक्ज़ीक्यूट करने की प्रोसेस गड़बड़ी के साथ खत्म हो जाती है. गड़बड़ी में, दिया गया message शामिल है.
प्रॉम्प्ट के उदाहरण:
cond |
res |
switch_on(cond, res, error("no condition matched")) |
|---|---|---|
TRUE |
1L | 1L |
FALSE |
1L | ERROR ("no condition matched") |
रेफ़रंस फ़ंक्शन
REFERENCE टाइप, डेटाबेस (या अन्य डेटाबेस) में मौजूद अन्य दस्तावेज़ों के लिए "पॉइंटर" के तौर पर काम करता है. क्वेरी को लागू करने के दौरान, इन फ़ंक्शन की मदद से इस टाइप में बदलाव किया जा सकता है.
| नाम | ब्यौरा |
COLLECTION_ID
|
यह फ़ंक्शन, दिए गए रेफ़रंस में लीफ़ कलेक्शन का आईडी दिखाता है |
DOCUMENT_ID
|
दिए गए रेफ़रंस में मौजूद दस्तावेज़ का आईडी दिखाता है |
PARENT
|
यह पैरंट रेफ़रंस दिखाता है |
REFERENCE_SLICE
|
यह फ़ंक्शन, दिए गए रेफ़रंस से सेगमेंट का सबसेट दिखाता है |
COLLECTION_ID
सिंटैक्स:
collection_id(ref: REFERENCE) -> STRING
जानकारी:
यह फ़ंक्शन, दिए गए REFERENCE का लीफ़ कलेक्शन आईडी दिखाता है.
प्रॉम्प्ट के उदाहरण:
ref |
collection_id(ref) |
|---|---|
users/user1 |
"users" |
users/user1/posts/post1 |
"posts" |
DOCUMENT_ID
सिंटैक्स:
document_id(ref: REFERENCE) -> ANY
जानकारी:
यह दिए गए REFERENCE का दस्तावेज़ आईडी दिखाता है.
प्रॉम्प्ट के उदाहरण:
ref |
document_id(ref) |
|---|---|
users/user1 |
"user1" |
users/user1/posts/post1 |
"post1" |
अभिभावक
सिंटैक्स:
parent(ref: REFERENCE) -> REFERENCE
जानकारी:
दिए गए रेफ़रंस का पैरंट REFERENCE दिखाता है. अगर रेफ़रंस पहले से ही रूट रेफ़रंस है, तो NULL दिखाता है.
प्रॉम्प्ट के उदाहरण:
ref |
parent(ref) |
|---|---|
/ |
NULL |
users/user1 |
/ |
users/user1/posts/post1 |
users/user1 |
REFERENCE_SLICE
सिंटैक्स:
reference_slice(ref: REFERENCE, offset: INT, length: INT) -> REFERENCE
जानकारी:
REFERENCE, (collection_id, document_id) ट्यूपल की एक सूची है. इससे उस सूची को देखा जा सकता है, ठीक वैसे ही जैसे array_slice(...) को देखा जाता है.
यह एक नया REFERENCE दिखाता है, जो दिए गए ref के सेगमेंट का सबसेट होता है.
offset: स्लाइस का शुरुआती इंडेक्स (0 से शुरू होने वाला). अगर यह वैल्यू नेगेटिव है, तो यह रेफ़रंस के आखिर से ऑफ़सेट है.length: स्लाइस में शामिल किए जाने वाले सेगमेंट की संख्या.
प्रॉम्प्ट के उदाहरण:
ref |
offset |
length |
reference_slice(ref, offset, length) |
|---|---|---|---|
a/1/b/2/c/3 |
1L | 2L | b/2/c/3 |
a/1/b/2/c/3 |
0L | 2L | a/1/b/2 |
a/1/b/2/c/3 |
-2L | 2L | c/3 |
लॉजिकल फ़ंक्शन
| नाम | ब्यौरा |
AND
|
लॉजिकल AND का इस्तेमाल करना |
OR
|
लॉजिकल OR का इस्तेमाल करना |
XOR
|
लॉजिकल XOR करता है |
NOT
|
लॉजिकल NOT का इस्तेमाल करता है |
NOR
|
लॉजिकल NOR फ़ंक्शन को लागू करता है |
CONDITIONAL
|
शर्त से जुड़े एक्सप्रेशन के आधार पर, ब्रांच का आकलन करता है. |
IF_NULL
|
यह फ़ंक्शन, पहली नॉन-नुल वैल्यू दिखाता है |
SWITCH_ON
|
शर्तों की सीरीज़ के आधार पर ब्रांच का आकलन |
EQUAL_ANY
|
इससे यह जांच की जाती है कि कोई वैल्यू, किसी कलेक्शन में मौजूद किसी एलिमेंट के बराबर है या नहीं |
NOT_EQUAL_ANY
|
यह पता लगाता है कि कोई वैल्यू, किसी कलेक्शन में मौजूद किसी भी एलिमेंट के बराबर है या नहीं |
MAXIMUM
|
वैल्यू के किसी सेट में मौजूद सबसे बड़ी वैल्यू दिखाता है |
MINIMUM
|
वैल्यू के किसी सेट में मौजूद सबसे छोटी वैल्यू दिखाता है |
और
सिंटैक्स:
and(x: BOOLEAN...) -> BOOLEAN
जानकारी:
दो या उससे ज़्यादा बूलियन वैल्यू का लॉजिकल AND दिखाता है.
अगर दी गई किसी भी वैल्यू के ABSENT या NULL होने की वजह से नतीजा नहीं निकाला जा सकता, तो NULL दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
and(x, y) |
|---|---|---|
TRUE |
TRUE |
TRUE |
FALSE |
TRUE |
FALSE |
NULL |
TRUE |
NULL |
ABSENT |
TRUE |
NULL |
NULL |
FALSE |
FALSE |
FALSE |
ABSENT |
FALSE |
Node.js
const result = await db.pipeline() .collection("books") .select( and(field("rating").greaterThan(4), field("price").lessThan(10)) .as("under10Recommendation") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( and(field("rating").greaterThan(4), field("price").lessThan(10)) .as("under10Recommendation") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ (Field("rating").greaterThan(4) && Field("price").lessThan(10)) .as("under10Recommendation") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( Expression.and(field("rating").greaterThan(4), field("price").lessThan(10)) .alias("under10Recommendation") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( Expression.and( field("rating").greaterThan(4), field("price").lessThan(10) ).alias("under10Recommendation") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, And result = ( client.pipeline() .collection("books") .select( And( Field.of("rating").greater_than(4), Field.of("price").less_than(10) ).as_("under10Recommendation") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( and(greaterThan(field("rating"), 4), lessThan(field("price"), 10)) .as("under10Recommendation")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.And( firestore.GreaterThan(firestore.FieldOf("rating"), 4), firestore.LessThan(firestore.FieldOf("price"), 10), ).As("under10Recommendation"), )). Execute(ctx)
या
सिंटैक्स:
or(x: BOOLEAN...) -> BOOLEAN
जानकारी:
दो या उससे ज़्यादा बूलियन वैल्यू का लॉजिकल OR दिखाता है.
अगर दी गई किसी भी वैल्यू के ABSENT या NULL होने की वजह से नतीजा नहीं निकाला जा सकता, तो NULL दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
or(x, y) |
|---|---|---|
TRUE |
TRUE |
TRUE |
FALSE |
TRUE |
TRUE |
NULL |
TRUE |
TRUE |
ABSENT |
TRUE |
TRUE |
NULL |
FALSE |
NULL |
FALSE |
ABSENT |
NULL |
Node.js
const result = await db.pipeline() .collection("books") .select( or(field("genre").equal("Fantasy"), field("tags").arrayContains("adventure")) .as("matchesSearchFilters") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( or(field("genre").equal("Fantasy"), field("tags").arrayContains("adventure")) .as("matchesSearchFilters") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ (Field("genre").equal("Fantasy") || Field("tags").arrayContains("adventure")) .as("matchesSearchFilters") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( Expression.or(field("genre").equal("Fantasy"), field("tags").arrayContains("adventure")) .alias("matchesSearchFilters") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( Expression.or( field("genre").equal("Fantasy"), field("tags").arrayContains("adventure") ).alias("matchesSearchFilters") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, And, Or result = ( client.pipeline() .collection("books") .select( Or( Field.of("genre").equal("Fantasy"), Field.of("tags").array_contains("adventure"), ).as_("matchesSearchFilters") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( or(equal(field("genre"), "Fantasy"), arrayContains(field("tags"), "adventure")) .as("matchesSearchFilters")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Or( firestore.Equal(firestore.FieldOf("genre"), "Fantasy"), firestore.ArrayContains(firestore.FieldOf("tags"), "adventure"), ).As("matchesSearchFilters"), )). Execute(ctx)
XOR
सिंटैक्स:
xor(x: BOOLEAN...) -> BOOLEAN
जानकारी:
दो या उससे ज़्यादा बूलियन वैल्यू का लॉजिकल XOR दिखाता है.
अगर दी गई कोई भी वैल्यू ABSENT या NULL है, तो NULL दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
xor(x, y) |
|---|---|---|
TRUE |
TRUE |
FALSE |
FALSE |
FALSE |
FALSE |
FALSE |
TRUE |
TRUE |
NULL |
TRUE |
NULL |
ABSENT |
TRUE |
NULL |
NULL |
FALSE |
NULL |
FALSE |
ABSENT |
NULL |
Node.js
const result = await execute(db.pipeline() .collection("books") .select( xor(field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction")) .as("matchesSearchFilters") ) );
Web
const result = await execute(db.pipeline() .collection("books") .select( xor(field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction")) .as("matchesSearchFilters") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ (Field("tags").arrayContains("magic") ^ Field("tags").arrayContains("nonfiction")) .as("matchesSearchFilters") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( Expression.xor(field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction")) .alias("matchesSearchFilters") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( Expression.xor( field("tags").arrayContains("magic"), field("tags").arrayContains("nonfiction") ).alias("matchesSearchFilters") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, Xor result = ( client.pipeline() .collection("books") .select( Xor( [ Field.of("tags").array_contains("magic"), Field.of("tags").array_contains("nonfiction"), ] ).as_("matchesSearchFilters") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( xor( arrayContains(field("tags"), "magic"), arrayContains(field("tags"), "nonfiction")) .as("matchesSearchFilters")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Xor( firestore.ArrayContains(firestore.FieldOf("tags"), "magic"), firestore.ArrayContains(firestore.FieldOf("tags"), "nonfiction"), ).As("matchesSearchFilters"), )). Execute(ctx)
NOR
सिंटैक्स:
nor(x: BOOLEAN...) -> BOOLEAN
जानकारी:
दो या उससे ज़्यादा बूलियन वैल्यू का लॉजिकल NOR दिखाता है.
अगर दी गई किसी भी वैल्यू के ABSENT या NULL होने की वजह से नतीजा नहीं निकाला जा सकता, तो NULL दिखाता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
nor(x, y) |
|---|---|---|
TRUE |
TRUE |
FALSE |
FALSE |
TRUE |
FALSE |
FALSE |
FALSE |
TRUE |
NULL |
TRUE |
FALSE |
ABSENT |
TRUE |
FALSE |
NULL |
FALSE |
NULL |
FALSE |
ABSENT |
NULL |
नहीं
सिंटैक्स:
not(x: BOOLEAN) -> BOOLEAN
जानकारी:
बूलियन वैल्यू का लॉजिकल NOT दिखाता है.
Node.js
const result = await execute(db.pipeline() .collection("books") .select( field("tags").arrayContains("nonfiction").not() .as("isFiction") ) );
Web
const result = await execute(db.pipeline() .collection("books") .select( field("tags").arrayContains("nonfiction").not() .as("isFiction") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ (!Field("tags").arrayContains("nonfiction")) .as("isFiction") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( Expression.not( field("tags").arrayContains("nonfiction") ).alias("isFiction") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( Expression.not( field("tags").arrayContains("nonfiction") ).alias("isFiction") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field, Not result = ( client.pipeline() .collection("books") .select(Not(Field.of("tags").array_contains("nonfiction")).as_("isFiction")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(not(arrayContains(field("tags"), "nonfiction")).as("isFiction")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.Not(firestore.ArrayContains(firestore.FieldOf("tags"), "nonfiction")).As("isFiction"), )). Execute(ctx)
शर्तों के साथ
सिंटैक्स:
conditional(condition: BOOLEAN, true_case: ANY, false_case: ANY) -> ANY
जानकारी:
अगर condition की वैल्यू TRUE होती है, तो यह फ़ंक्शन true_case दिखाता है.
अगर शर्त FALSE, NULL या ABSENT वैल्यू के तौर पर पूरी होती है, तो यह फ़ंक्शन false_case का आकलन करता है और उसे दिखाता है.
प्रॉम्प्ट के उदाहरण:
condition |
true_case |
false_case |
conditional(condition, true_case, false_case) |
|---|---|---|---|
TRUE |
1L | 0L | 1L |
FALSE |
1L | 0L | 0L |
NULL |
1L | 0L | 0L |
ABSENT |
1L | 0L | 0L |
Node.js
const result = await execute(db.pipeline() .collection("books") .select( field("tags").arrayConcat([ field("pages").greaterThan(100) .conditional(constant("longRead"), constant("shortRead")) ]).as("extendedTags") ) );
Web
const result = await execute(db.pipeline() .collection("books") .select( field("tags").arrayConcat([ field("pages").greaterThan(100) .conditional(constant("longRead"), constant("shortRead")) ]).as("extendedTags") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("tags").arrayConcat([ ConditionalExpression( Field("pages").greaterThan(100), then: Constant("longRead"), else: Constant("shortRead") ) ]).as("extendedTags") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("tags").arrayConcat( Expression.conditional( field("pages").greaterThan(100), constant("longRead"), constant("shortRead") ) ).alias("extendedTags") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("tags").arrayConcat( Expression.conditional( field("pages").greaterThan(100), constant("longRead"), constant("shortRead") ) ).alias("extendedTags") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import ( Field, Constant, Conditional, ) result = ( client.pipeline() .collection("books") .select( Field.of("tags") .array_concat( Conditional( Field.of("pages").greater_than(100), Constant.of("longRead"), Constant.of("shortRead"), ) ) .as_("extendedTags") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayConcat( field("tags"), conditional( greaterThan(field("pages"), 100), constant("longRead"), constant("shortRead"))) .as("extendedTags")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.ArrayConcat( firestore.FieldOf("tags"), firestore.Conditional( firestore.GreaterThan(firestore.FieldOf("pages"), 100), firestore.ConstantOf("longRead"), firestore.ConstantOf("shortRead"), ), ).As("extendedTags"), )). Execute(ctx)
IF_NULL
सिंटैक्स:
if_null(expr: ANY, replacement: ANY) -> ANY
जानकारी:
अगर वैल्यू NULL नहीं है, तो expr दिखाता है. अगर वैल्यू है, तो
replacement का आकलन करके उसे दिखाता है. अगर expr का इस्तेमाल किया जाता है, तो replacement एक्सप्रेशन का आकलन नहीं किया जाता.
प्रॉम्प्ट के उदाहरण:
expr |
replacement |
if_null(expr, replacement) |
|---|---|---|
| 1L | 2L | 1L |
NULL |
2L | 2L |
ABSENT |
2L | ABSENT |
SWITCH_ON
सिंटैक्स:
switch_on(cond1: BOOLEAN, res1: ANY, cond2: BOOLEAN, res2: ANY, ..., [default: ANY]) -> ANY
जानकारी:
यह फ़ंक्शन, कई शर्तों का आकलन करता है और पहली TRUE शर्त से जुड़ा नतीजा दिखाता है. अगर कोई भी शर्त TRUE नहीं है, तो default वैल्यू
दिखाई जाती है. हालांकि, इसके लिए ज़रूरी है कि वैल्यू दी गई हो. अगर default की कोई वैल्यू नहीं दी जाती है, तो गड़बड़ी का मैसेज दिखता है. ऐसा तब होता है, जब कोई अन्य शर्त TRUE के तौर पर नहीं दिखती.
default वैल्यू देने के लिए, इसे आखिरी आर्ग्युमेंट के तौर पर पास करें, ताकि आर्ग्युमेंट की संख्या विषम हो.
प्रॉम्प्ट के उदाहरण:
x |
switch_on(eq(x, 1L), "one", eq(x, 2L), "two", "other") |
|---|---|
| 1L | "one" |
| 2L | "दो" |
| 3L | "अन्य" |
EQUAL_ANY
सिंटैक्स:
equal_any(value: ANY, search_space: ARRAY) -> BOOLEAN
जानकारी:
अगर value, search_space कलेक्शन में मौजूद है, तो TRUE दिखाता है.
प्रॉम्प्ट के उदाहरण:
value |
search_space |
equal_any(value, search_space) |
|---|---|---|
| 0L | [1L, 2L, 3L] | FALSE |
| 2L | [1L, 2L, 3L] | TRUE |
NULL |
[1L, 2L, 3L] | FALSE |
NULL |
[1L, NULL] |
TRUE |
ABSENT |
[1L, NULL] |
FALSE |
| NaN | [1L, NaN, 3L] | TRUE |
Node.js
const result = await execute(db.pipeline() .collection("books") .select( field("genre").equalAny(["Science Fiction", "Psychological Thriller"]) .as("matchesGenreFilters") ) );
Web
const result = await execute(db.pipeline() .collection("books") .select( field("genre").equalAny(["Science Fiction", "Psychological Thriller"]) .as("matchesGenreFilters") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("genre").equalAny(["Science Fiction", "Psychological Thriller"]) .as("matchesGenreFilters") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre").equalAny(listOf("Science Fiction", "Psychological Thriller")) .alias("matchesGenreFilters") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre").equalAny(Arrays.asList("Science Fiction", "Psychological Thriller")) .alias("matchesGenreFilters") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("genre") .equal_any(["Science Fiction", "Psychological Thriller"]) .as_("matchesGenreFilters") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( equalAny(field("genre"), Arrays.asList("Science Fiction", "Psychological Thriller")) .as("matchesGenreFilters")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.EqualAny(firestore.FieldOf("genre"), []string{"Science Fiction", "Psychological Thriller"}).As("matchesGenreFilters"), )). Execute(ctx)
NOT_EQUAL_ANY
सिंटैक्स:
not_equal_any(value: ANY, search_space: ARRAY) -> BOOLEAN
जानकारी:
अगर value, search_space कलेक्शन में मौजूद नहीं है, तो TRUE दिखाता है.
प्रॉम्प्ट के उदाहरण:
value |
search_space |
not_equal_any(value, search_space) |
|---|---|---|
| 0L | [1L, 2L, 3L] | TRUE |
| 2L | [1L, 2L, 3L] | FALSE |
NULL |
[1L, 2L, 3L] | TRUE |
NULL |
[1L, NULL] |
FALSE |
ABSENT |
[1L, NULL] |
TRUE |
| NaN | [1L, NaN, 3L] | FALSE |
Node.js
const result = await execute(db.pipeline() .collection("books") .select( field("author").notEqualAny(["George Orwell", "F. Scott Fitzgerald"]) .as("byExcludedAuthors") ) );
Web
const result = await execute(db.pipeline() .collection("books") .select( field("author").notEqualAny(["George Orwell", "F. Scott Fitzgerald"]) .as("byExcludedAuthors") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("author").notEqualAny(["George Orwell", "F. Scott Fitzgerald"]) .as("byExcludedAuthors") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("author").notEqualAny(listOf("George Orwell", "F. Scott Fitzgerald")) .alias("byExcludedAuthors") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("author").notEqualAny(Arrays.asList("George Orwell", "F. Scott Fitzgerald")) .alias("byExcludedAuthors") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("author") .not_equal_any(["George Orwell", "F. Scott Fitzgerald"]) .as_("byExcludedAuthors") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( notEqualAny(field("author"), Arrays.asList("George Orwell", "F. Scott Fitzgerald")) .as("byExcludedAuthors")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.NotEqualAny(firestore.FieldOf("author"), []string{"George Orwell", "F. Scott Fitzgerald"}).As("byExcludedAuthors"), )). Execute(ctx)
MAXIMUM
सिंटैक्स:
maximum(x: ANY...) -> ANY
maximum(x: ARRAY) -> ANY
जानकारी:
वैल्यू की सीरीज़ x में, ज़्यादा से ज़्यादा ऐसी वैल्यू दिखाता है जो न तो NULL हो और न ही ABSENT.
अगर कोई भी वैल्यू NULL या ABSENT नहीं है, तो NULL दिखेगा.
अगर एक से ज़्यादा वैल्यू सबसे बड़ी हैं, तो उनमें से कोई भी वैल्यू दिखाई जा सकती है. वैल्यू टाइप का क्रम, दस्तावेज़ में दिए गए क्रम के मुताबिक होता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
maximum(x, y) |
|---|---|---|
FALSE |
TRUE |
TRUE |
FALSE |
-10L | -10L |
| 0.0 | -5L | 0.0 |
| "foo" | "bar" | "foo" |
| "foo" | ["foo"] | ["foo"] |
ABSENT |
ABSENT |
NULL |
NULL |
NULL |
NULL |
Node.js
const result = await execute(db.pipeline() .collection("books") .aggregate(field("price").maximum().as("maximumPrice")) );
Web
const result = await execute(db.pipeline() .collection("books") .aggregate(field("price").maximum().as("maximumPrice")) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("rating").logicalMaximum([1]).as("flooredRating") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("rating").logicalMaximum(1).alias("flooredRating") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("rating").logicalMaximum(1).alias("flooredRating") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").logical_maximum(1).as_("flooredRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(logicalMaximum(field("rating"), 1).as("flooredRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.LogicalMaximum(firestore.FieldOf("rating"), 1).As("flooredRating"), )). Execute(ctx)
MINIMUM
सिंटैक्स:
minimum(x: ANY...) -> ANY
minimum(x: ARRAY) -> ANY
जानकारी:
वैल्यू की सीरीज़ x में, NULL और ABSENT के अलावा सबसे छोटी वैल्यू दिखाता है.
अगर कोई भी वैल्यू NULL या ABSENT नहीं है, तो NULL दिखेगा.
अगर एक जैसी कई वैल्यू हैं, तो उनमें से कोई भी वैल्यू दिखाई जा सकती है. वैल्यू टाइप का क्रम, दस्तावेज़ में दिए गए क्रम के मुताबिक होता है.
प्रॉम्प्ट के उदाहरण:
x |
y |
minimum(x, y) |
|---|---|---|
FALSE |
TRUE |
FALSE |
FALSE |
-10L | FALSE |
| 0.0 | -5L | -5L |
| "foo" | "bar" | "bar" |
| "foo" | ["foo"] | "foo" |
ABSENT |
ABSENT |
NULL |
NULL |
NULL |
NULL |
Node.js
const result = await execute(db.pipeline() .collection("books") .aggregate(field("price").minimum().as("minimumPrice")) );
Web
const result = await execute(db.pipeline() .collection("books") .aggregate(field("price").minimum().as("minimumPrice")) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("rating").logicalMinimum([5]).as("cappedRating") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("rating").logicalMinimum(5).alias("cappedRating") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("rating").logicalMinimum(5).alias("cappedRating") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").logical_minimum(5).as_("cappedRating")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(logicalMinimum(field("rating"), 5).as("cappedRating")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.LogicalMinimum(firestore.FieldOf("rating"), 5).As("cappedRating"), )). Execute(ctx)
मैप फ़ंक्शन
| नाम | ब्यौरा |
MAP
|
की-वैल्यू पेयर की सीरीज़ से मैप वैल्यू बनाता है |
MAP_GET
|
यह फ़ंक्शन, किसी मैप में मौजूद वैल्यू को दिखाता है. इसके लिए, आपको एक कुंजी देनी होगी |
MAP_SET
|
अपडेट की गई कुंजियों की सीरीज़ के साथ मैप की कॉपी दिखाता है |
MAP_REMOVE
|
मैप की एक कॉपी दिखाता है, जिसमें से कुंजियों की एक सीरीज़ हटा दी गई है |
MAP_MERGE
|
मैप की सीरीज़ को एक साथ मर्ज करता है. |
CURRENT_CONTEXT
|
मौजूदा कॉन्टेक्स्ट को मैप के तौर पर दिखाता है. |
MAP_KEYS
|
यह फ़ंक्शन, मैप में मौजूद सभी कुंजियों का कलेक्शन दिखाता है. |
MAP_VALUES
|
यह फ़ंक्शन, मैप में मौजूद सभी वैल्यू का ऐरे दिखाता है. |
MAP_ENTRIES
|
यह फ़ंक्शन, मैप के की-वैल्यू पेयर का ऐरे दिखाता है. |
मानचित्र
सिंटैक्स:
map(key: STRING, value: ANY, ...) -> MAP
जानकारी:
यह की-वैल्यू पेयर की सीरीज़ से मैप बनाता है.
MAP_GET
सिंटैक्स:
map_get(map: ANY, key: STRING) -> ANY
जानकारी:
यह फ़ंक्शन, किसी मैप में दी गई कुंजी की वैल्यू दिखाता है. अगर मैप में key मौजूद नहीं है या map आर्ग्युमेंट MAP नहीं है, तो ABSENT वैल्यू दिखाता है.
Node.js
const result = await db.pipeline() .collection("books") .select( field("awards").mapGet("pulitzer").as("hasPulitzerAward") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("awards").mapGet("pulitzer").as("hasPulitzerAward") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("awards").mapGet("pulitzer").as("hasPulitzerAward") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("awards").mapGet("pulitzer").alias("hasPulitzerAward") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("awards").mapGet("pulitzer").alias("hasPulitzerAward") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("awards").map_get("pulitzer").as_("hasPulitzerAward")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.MapGet(firestore.FieldOf("awards"), "pulitzer").As("hasPulitzerAward"), )). Execute(ctx)
MAP_SET
सिंटैक्स:
map_set(map: MAP, key: STRING, value: ANY, ...) -> MAP
जानकारी:
यह फ़ंक्शन, map वैल्यू की एक कॉपी दिखाता है. इस कॉपी में मौजूद कॉन्टेंट को की-वैल्यू पेयर की सीरीज़ से अपडेट किया जाता है.
अगर दी गई वैल्यू मौजूद नहीं है, तो उससे जुड़ी कुंजी को मैप से हटा दिया जाता है.
अगर map आर्ग्युमेंट MAP नहीं है, तो यह फ़ंक्शन कोई वैल्यू नहीं दिखाता.
MAP_REMOVE
सिंटैक्स:
map_remove(map: MAP, key: STRING...) -> MAP
जानकारी:
कुंजियों की सीरीज़ को हटाकर, map वैल्यू की कॉपी दिखाता है.
MAP_MERGE
सिंटैक्स:
map_merge(maps: MAP...) -> MAP
दो या उससे ज़्यादा मैप के कॉन्टेंट को मर्ज करता है. अगर कई मैप में अलग-अलग वैल्यू हैं, तो आखिरी वैल्यू का इस्तेमाल किया जाता है.
CURRENT_CONTEXT
सिंटैक्स:
current_context() -> MAP
यह फ़ंक्शन, मौजूदा पॉइंट ऑफ़ एक्ज़ीक्यूशन में उपलब्ध सभी फ़ील्ड का मैप दिखाता है.
MAP_KEYS
सिंटैक्स:
map_keys(map: MAP) -> ARRAY<STRING>
जानकारी:
यह map वैल्यू की सभी कुंजियों वाली श्रेणी दिखाता है.
MAP_VALUES
सिंटैक्स:
map_values(map: MAP) -> ARRAY<ANY>
जानकारी:
यह map वैल्यू की सभी वैल्यू वाली श्रेणी दिखाता है.
MAP_ENTRIES
सिंटैक्स:
map_entries(map: MAP) -> ARRAY<MAP>
जानकारी:
यह map वैल्यू में मौजूद सभी की-वैल्यू पेयर वाली श्रेणी दिखाता है.
हर की-वैल्यू पेयर, दो एंट्री वाले मैप के तौर पर होगा: k और v.
प्रॉम्प्ट के उदाहरण:
map |
map_entries(map) |
|---|---|
| {} | [] |
| {"foo" : 2L} | [{"k": "foo", "v" : 2L}] |
| {"foo" : "bar", "bar" : "foo"} | [{"k": "foo", "v" : "bar" }, {"k" : "bar", "v": "foo"}] |
स्ट्रिंग फ़ंक्शन
| नाम | ब्यौरा |
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" | गड़बड़ी |
टाइमस्टैंप फ़ंक्शन
| नाम | ब्यौरा |
CURRENT_TIMESTAMP
|
अनुरोध के समय के हिसाब से TIMESTAMP जनरेट करता है.
|
TIMESTAMP_TRUNC
|
यह फ़ंक्शन, TIMESTAMP को जानकारी के दिए गए स्तर के मुताबिक बदल देता है.
|
UNIX_MICROS_TO_TIMESTAMP
|
1970-01-01 00:00:00 UTC से अब तक के माइक्रोसेकंड की संख्या को TIMESTAMP में बदलता है
|
UNIX_MILLIS_TO_TIMESTAMP
|
1970-01-01 00:00:00 UTC से अब तक के मिलीसेकंड की संख्या को TIMESTAMP में बदलता है
|
UNIX_SECONDS_TO_TIMESTAMP
|
1970-01-01 00:00:00 UTC से लेकर अब तक के सेकंड की संख्या को TIMESTAMP में बदलता है
|
TIMESTAMP_ADD
|
TIMESTAMP में समय का अंतराल जोड़ता है
|
TIMESTAMP_SUB
|
यह फ़ंक्शन, TIMESTAMP से किसी समयावधि को घटाता है
|
TIMESTAMP_TO_UNIX_MICROS
|
TIMESTAMP को 1970-01-01 00:00:00 UTC के बाद के माइक्रोसेकंड की संख्या में बदलता है
|
TIMESTAMP_TO_UNIX_MILLIS
|
यह TIMESTAMP को 1970-01-01 00:00:00 UTC के बाद से अब तक के मिलीसेकंड की संख्या में बदलता है
|
TIMESTAMP_TO_UNIX_SECONDS
|
TIMESTAMP को 1970-01-01 00:00:00 UTC के बाद से सेकंड की संख्या में बदलता है
|
TIMESTAMP_DIFF
|
यह फ़ंक्शन, दो TIMESTAMP के बीच unit के अंतराल की कुल संख्या दिखाता है.
|
TIMESTAMP_EXTRACT
|
किसी TIMESTAMP से कोई खास part (जैसे, साल, महीना, दिन) निकालता है.
|
CURRENT_TIMESTAMP
सिंटैक्स:
current_timestamp() -> TIMESTAMP
जानकारी:
अनुरोध के समय input की शुरुआत में टाइमस्टैंप मिलता है. इसे 1970-01-01 00:00:00 UTC के बाद से माइक्रोसेकंड की संख्या के तौर पर समझा जाता है.
यह किसी क्वेरी में स्थिर रहता है. साथ ही, कई बार कॉल किए जाने पर भी हमेशा एक ही वैल्यू पर रिज़ॉल्व होगा.
TIMESTAMP_TRUNC
सिंटैक्स:
timestamp_trunc(timestamp: TIMESTAMP | BSON_TIMESTAMP, granularity: STRING[, timezone: STRING]) -> TIMESTAMP
जानकारी:
जानकारी के बताए गए स्तर के मुताबिक टाइमस्टैंप को बदल देता है.
granularity आर्ग्युमेंट एक स्ट्रिंग होनी चाहिए. साथ ही, यह इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourdayweekweek([weekday])monthquarteryearisoyear
अगर timezone आर्ग्युमेंट दिया जाता है, तो ट्रंकेशन दिए गए टाइमज़ोन की कैलेंडर सीमाओं के आधार पर होगा. उदाहरण के लिए, दिन का ट्रंकेशन दिए गए टाइमज़ोन में आधी रात को ट्रंकेट हो जाएगा. ट्रंकेशन, डेलाइट सेविंग टाइम के हिसाब से होगा.
अगर timezone नहीं दिया गया है, तो ट्रंकेशन UTC कैलेंडर की सीमाओं पर आधारित होगा.
timezone आर्ग्युमेंट, tz डेटाबेस से टाइमज़ोन को दिखाने वाली स्ट्रिंग होनी चाहिए. उदाहरण के लिए, America/New_York. GMT से ऑफ़सेट तय करके, पसंद के मुताबिक टाइम ऑफ़सेट का भी इस्तेमाल किया जा सकता है.
प्रॉम्प्ट के उदाहरण:
timestamp |
granularity |
timezone |
timestamp_trunc(timestamp, granularity, timezone) |
|---|---|---|---|
| 2000-01-01 10:20:30:123456 यूटीसी | "दूसरा" | नहीं दिया गया | 2001-01-01 10:20:30 यूटीसी |
| 1997-05-31 04:30:30 UTC | "दिन" | नहीं दिया गया | 1997-05-31 00:00:00 यूटीसी |
| 1997-05-31 04:30:30 UTC | "दिन" | "America/Los_Angeles" | 1997-05-30 07:00:00 यूटीसी |
| 2001-03-16 04:00:00 यूटीसी | "week(friday) | नहीं दिया गया | 2001-03-16 00:00:00 यूटीसी |
| 2001-03-23 04:00:00 यूटीसी | "week(friday) | "America/Los_Angeles" | 2001-03-23 17:00:00 यूटीसी |
| 24-01-2026 रात 08:00:00 बजे यूटीसी | "महीना" | "GMT+06:32:43" | 2026-01-01T06:32:43 यूटीसी |
UNIX_MICROS_TO_TIMESTAMP
सिंटैक्स:
unix_micros_to_timestamp(input: INT64) -> TIMESTAMP
जानकारी:
input को TIMESTAMP में बदलता है. को
1970-01-01 00:00:00 UTC के बाद के माइक्रोसेकंड की संख्या के तौर पर इंटरप्रेट किया जाता है. अगर input को मान्य TIMESTAMP में नहीं बदला जा सकता, तो error दिखाता है.
प्रॉम्प्ट के उदाहरण:
input |
unix_micros_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 यूटीसी |
| 400123456L | 1970-01-01 00:06:40.123456 यूटीसी |
| -1000000L | 1969-12-31 23:59:59 यूटीसी |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("createdAtMicros") .unix_micros_to_timestamp() .as_("createdAtString") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(unixMicrosToTimestamp(field("createdAtMicros")).as("createdAtString")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.UnixMicrosToTimestamp(firestore.FieldOf("createdAtMicros")).As("createdAtString"), )). Execute(ctx)
UNIX_MILLIS_TO_TIMESTAMP
सिंटैक्स:
unix_millis_to_timestamp(input: INT64) -> TIMESTAMP
जानकारी:
यह input को TIMESTAMP में बदलता है. input को 1970-01-01 00:00:00 UTC के बाद से मिलीसेकंड की संख्या के तौर पर इंटरप्रेट किया जाता है. अगर input को मान्य TIMESTAMP में नहीं बदला जा सकता, तो error दिखाता है.
प्रॉम्प्ट के उदाहरण:
input |
unix_millis_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 यूटीसी |
| 4000123L | 1970-01-01 01:06:40.123 यूटीसी |
| -1000000L | 1969-12-31 23:43:20 यूटीसी |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().as("createdAtString") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().as("createdAtString") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAtMillis").unixMillisToTimestamp().as("createdAtString") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("createdAtMillis") .unix_millis_to_timestamp() .as_("createdAtString") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(unixMillisToTimestamp(field("createdAtMillis")).as("createdAtString")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.UnixMillisToTimestamp(firestore.FieldOf("createdAtMillis")).As("createdAtString"), )). Execute(ctx)
UNIX_SECONDS_TO_TIMESTAMP
सिंटैक्स:
unix_seconds_to_timestamp(input: INT64) -> TIMESTAMP
जानकारी:
यह input (1970-01-01 00:00:00 UTC के बाद के सेकंड की संख्या के तौर पर इंटरप्रेट किया गया) को TIMESTAMP में बदलता है. अगर input को मान्य TIMESTAMP में नहीं बदला जा सकता, तो error दिखाता है.
प्रॉम्प्ट के उदाहरण:
input |
unix_seconds_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 यूटीसी |
| 60L | 1970-01-01 00:01:00 यूटीसी |
| -300L | 1969-12-31 23:55:00 यूटीसी |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("createdAtSeconds") .unix_seconds_to_timestamp() .as_("createdAtString") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(unixSecondsToTimestamp(field("createdAtSeconds")).as("createdAtString")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.UnixSecondsToTimestamp(firestore.FieldOf("createdAtSeconds")).As("createdAtString"), )). Execute(ctx)
TIMESTAMP_ADD
सिंटैक्स:
timestamp_add(timestamp: TIMESTAMP | BSON_TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP
जानकारी:
timestamp से unit का amount जोड़ता है. amount आर्ग्युमेंट की वैल्यू नेगेटिव हो सकती है. ऐसे में, यह TIMESTAMP_SUB के बराबर होता है.
unit आर्ग्युमेंट एक स्ट्रिंग होनी चाहिए. साथ ही, यह इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourday
अगर नतीजे के तौर पर मिलने वाला टाइमस्टैंप, TIMESTAMP रेंज में नहीं आता है, तो गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
timestamp |
unit |
amount |
timestamp_add(timestamp, unit, amount) |
|---|---|---|---|
| 20-02-2025 00:00:00 यूटीसी | "मिनट" | 2L | 2025-02-20 00:02:00 यूटीसी |
| 20-02-2025 00:00:00 यूटीसी | "घंटा" | -4L | 19-02-2025 रात 08:00:00 बजे यूटीसी |
| 20-02-2025 00:00:00 यूटीसी | "दिन" | 5 लाख | 25-02-2025 00:00:00 यूटीसी |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("createdAt").timestampAdd("day", 3653).as("expiresAt") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAt").timestampAdd("day", 3653).as("expiresAt") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAt").timestampAdd(3653, .day).as("expiresAt") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAt") .timestampAdd("day", 3653) .alias("expiresAt") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAt").timestampAdd("day", 3653).alias("expiresAt") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("createdAt").timestamp_add("day", 3653).as_("expiresAt")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampAdd(field("createdAt"), "day", 3653).as("expiresAt")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.TimestampAdd(firestore.FieldOf("createdAt"), "day", 3653).As("expiresAt"), )). Execute(ctx)
TIMESTAMP_SUB
सिंटैक्स:
timestamp_sub(timestamp: TIMESTAMP | BSON_TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP
जानकारी:
timestamp से unit का amount घटाता है. amount आर्ग्युमेंट की वैल्यू नेगेटिव हो सकती है. ऐसे में, यह TIMESTAMP_ADD के बराबर होता है.
unit आर्ग्युमेंट एक स्ट्रिंग होनी चाहिए. साथ ही, यह इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourday
अगर नतीजे के तौर पर मिलने वाला टाइमस्टैंप, TIMESTAMP रेंज में नहीं आता है, तो गड़बड़ी का मैसेज दिखता है.
प्रॉम्प्ट के उदाहरण:
timestamp |
unit |
amount |
timestamp_sub(timestamp, unit, amount) |
|---|---|---|---|
| 04-07-2026 00:00:00 यूटीसी | "मिनट" | 40L | 2026-07-03 23:20:00 यूटीसी |
| 04-07-2026 00:00:00 यूटीसी | "घंटा" | -24L | 05-07-2026 00:00:00 यूटीसी |
| 04-07-2026 00:00:00 यूटीसी | "दिन" | 3L | 01-07-2026 00:00:00 यूटीसी |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("expiresAt").timestampSubtract(14, .day).as("sendWarningTimestamp") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("expiresAt") .timestampSubtract("day", 14) .alias("sendWarningTimestamp") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("expiresAt").timestampSubtract("day", 14).alias("sendWarningTimestamp") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("expiresAt") .timestamp_subtract("day", 14) .as_("sendWarningTimestamp") ) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampSubtract(field("expiresAt"), "day", 14).as("sendWarningTimestamp")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.TimestampSubtract(firestore.FieldOf("expiresAt"), "day", 14).As("sendWarningTimestamp"), )). Execute(ctx)
TIMESTAMP_TO_UNIX_MICROS
सिंटैक्स:
timestamp_to_unix_micros(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64
जानकारी:
input को 1970-01-01 00:00:00 UTC के बाद से अब तक के माइक्रोसेकंड की संख्या में बदलता है.
यह माइक्रोसेकंड की शुरुआत तक राउंड डाउन करके, सटीक होने के ज़्यादा लेवल को छोटा करता है.
प्रॉम्प्ट के उदाहरण:
input |
timestamp_to_unix_micros(input) |
|---|---|
| 1970-01-01 00:00:00 यूटीसी | 0L |
| 1970-01-01 00:06:40.123456 यूटीसी | 400123456L |
| 1969-12-31 23:59:59 यूटीसी | -1000000L |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().as("unixMicros") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().as("unixMicros") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("dateString").timestampToUnixMicros().as("unixMicros") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().alias("unixMicros") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().alias("unixMicros") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("dateString").timestamp_to_unix_micros().as_("unixMicros")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampToUnixMicros(field("dateString")).as("unixMicros")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.TimestampToUnixMicros(firestore.FieldOf("dateString")).As("unixMicros"), )). Execute(ctx)
TIMESTAMP_TO_UNIX_MILLIS
सिंटैक्स:
timestamp_to_unix_millis(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64
जानकारी:
input को 1970-01-01 00:00:00 UTC के बाद से मिलीसेकंड की संख्या में बदलता है.
यह मिलीसेकंड की शुरुआत तक राउंड डाउन करके, सटीक होने के ज़्यादा लेवल को छोटा करता है.
प्रॉम्प्ट के उदाहरण:
input |
timestamp_to_unix_millis(input) |
|---|---|
| 1970-01-01 00:00:00 यूटीसी | 0L |
| 1970-01-01 01:06:40.123 यूटीसी | 4000123L |
| 1969-12-31 23:43:20 | -1000000L |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().as("unixMillis") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().as("unixMillis") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("dateString").timestampToUnixMillis().as("unixMillis") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().alias("unixMillis") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().alias("unixMillis") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("dateString").timestamp_to_unix_millis().as_("unixMillis")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampToUnixMillis(field("dateString")).as("unixMillis")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.TimestampToUnixMillis(firestore.FieldOf("dateString")).As("unixMillis"), )). Execute(ctx)
TIMESTAMP_TO_UNIX_SECONDS
सिंटैक्स:
timestamp_to_unix_seconds(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64
जानकारी:
input को 1970-01-01 00:00:00 UTC के बाद से सेकंड की संख्या में बदलता है.
यह सटीक होने के ज़्यादा लेवल को कम करके, सेकंड की शुरुआत तक राउंड डाउन करता है.
प्रॉम्प्ट के उदाहरण:
input |
timestamp_to_unix_seconds(input) |
|---|---|
| 1970-01-01 00:00:00 यूटीसी | 0L |
| 1970-01-01 00:01:00 यूटीसी | 60L |
| 1969-12-31 23:55:00 यूटीसी | -300L |
Node.js
const result = await db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().as("unixSeconds") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().as("unixSeconds") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("dateString").timestampToUnixSeconds().as("unixSeconds") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().alias("unixSeconds") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().alias("unixSeconds") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("dateString").timestamp_to_unix_seconds().as_("unixSeconds")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampToUnixSeconds(field("dateString")).as("unixSeconds")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("documents"). Select(firestore.Fields( firestore.TimestampToUnixSeconds(firestore.FieldOf("dateString")).As("unixSeconds"), )). Execute(ctx)
TIMESTAMP_DIFF
सिंटैक्स:
timestamp_diff(end: TIMESTAMP | BSON_TIMESTAMP, start: TIMESTAMP | BSON_TIMESTAMP, unit: STRING) -> INT64
जानकारी:
यह फ़ंक्शन, दो TIMESTAMP के बीच unit के अंतराल की कुल संख्या दिखाता है.
- अगर
end,startसे पहले आता है, तो नेगेटिव वैल्यू दिखाता है. - यह किसी भी फ़्रैक्शनल यूनिट को ट्रंकेट करता है. उदाहरण के लिए,
timestamp_diff("2021-01-01 00:00:01", "2021-01-01 00:00:00", "minute")से, नतीजे के तौर पर0मिलता है.
unit आर्ग्युमेंट एक स्ट्रिंग होनी चाहिए. साथ ही, यह इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourday
प्रॉम्प्ट के उदाहरण:
end |
start |
unit |
timestamp_diff(end, start, unit) |
|---|---|---|---|
| 04-07-2026 00:01:00 यूटीसी | 04-07-2026 00:00:00 यूटीसी | "दूसरा" | 60L |
| 04-07-2026 00:00:00 यूटीसी | 05-07-2026 00:00:00 यूटीसी | "दिन" | -1L |
| 04-07-2026 00:00:59 यूटीसी | 04-07-2026 00:00:00 यूटीसी | "मिनट" | 0L |
TIMESTAMP_EXTRACT
सिंटैक्स:
timestamp_extract(timestamp: TIMESTAMP | BSON_TIMESTAMP, part: STRING[, timezone: STRING]) -> INT64
जानकारी:
timestamp से कोई खास part (जैसे, साल, महीना, दिन) निकालता है.
part आर्ग्युमेंट एक स्ट्रिंग होनी चाहिए. साथ ही, यह इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourdaydayofweek: यह 1 (रविवार) और 7 (शनिवार) के बीच की कोई वैल्यू दिखाता है.dayofyearweek: यह साल के हफ़्ते का नंबर दिखाता है. साल के पहले रविवार के लिए, यह 1 से शुरू होता है.week([weekday]): यह किसी तारीख के लिए, साल के हफ़्ते की संख्या बताता है. यह संख्या, तय किए गएweekdayसे शुरू होती है.monthquarteryearisoweek: यह ISO 8601 के हिसाब से हफ़्ते की संख्या बताता है.isoyear: यह ISO 8601 के हिसाब से हफ़्ते की संख्या वाला साल बताता है.
अगर timezone आर्ग्युमेंट दिया गया है, तो दिए गए टाइमज़ोन के कैलेंडर के आधार पर जानकारी निकाली जाएगी. डेटा एक्सट्रैक्ट करने की प्रोसेस, डेलाइट सेविंग टाइम के हिसाब से होगी.
अगर timezone नहीं दिया गया है, तो डेटा UTC के आधार पर निकाला जाएगा.
timezone आर्ग्युमेंट, टाइमज़ोन डेटाबेस से टाइमज़ोन की स्ट्रिंग के तौर पर होना चाहिए. उदाहरण के लिए, America/New_York. GMT से ऑफ़सेट तय करके, कस्टम टाइम ऑफ़सेट का भी इस्तेमाल किया जा सकता है.
प्रॉम्प्ट के उदाहरण:
timestamp |
part |
timezone |
timestamp_extract(timestamp, part, timezone) |
|---|---|---|---|
| 2025-02-20 10:20:30 यूटीसी | "year" | नहीं दिया गया | 2025 |
| 2025-02-20 10:20:30 यूटीसी | "दिन" | नहीं दिया गया | 20 |
| 31-12-2025 को रात 11:59:59 बजे यूटीसी | "year" | "Asia/Tokyo" | 2026 |
टाइप फ़ंक्शन
| नाम | ब्यौरा |
TYPE
|
यह वैल्यू के टाइप को STRING के तौर पर दिखाता है.
|
IS_TYPE
|
अगर वैल्यू, बताए गए टाइप से मेल खाती है, तो true दिखाता है.
|
प्रकार
सिंटैक्स:
type(input: ANY) -> STRING
जानकारी:
यह फ़ंक्शन, input टाइप की स्ट्रिंग दिखाता है.
अगर कोई वैल्यू नहीं दी जाती है, तो यह NULL दिखाता है.
प्रॉम्प्ट के उदाहरण:
input |
type(input) |
|---|---|
| NULL | "null" |
| सही | "boolean" |
| 1 | "int32" |
| -3L | "int64" |
| 3.14 | "float64" |
| 2024-01-01T00:00:00Z यूटीसी | "timestamp" |
| "foo" | "string" |
| b"foo" | "bytes" |
| [1, 2] | "array" |
| "a": 1 | "map" |
path("c/d") |
"reference" |
vector([1.0, 2.0]) |
"vector" |
object_id "a7f2c9d18b3e4509f67c12d8" |
"object_id" |
1.2e9m |
"decimal128" |
regex "/pattern/i" |
"regex" |
bson_timestamp(1732754912, 500) |
"bson_timestamp" |
| अनुपस्थित | NULL |
क्लाइंट के उदाहरण
Node.js
const result = await db.pipeline() .collection("books") .select(field("title").notEqual("1984").as("not1984")) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select(field("title").notEqual("1984").as("not1984")) );
Swift
let result = try await db.pipeline() .collection("books") .select([Field("title").notEqual("1984").as("not1984")]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select(field("title").notEqual("1984").alias("not1984")) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select(field("title").notEqual("1984").alias("not1984")) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").not_equal("1984").as_("not1984")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(notEqual(field("title"), "1984").as("not1984")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.NotEqual(firestore.FieldOf("title"), "1984").As("not1984"), )). Execute(ctx)
IS_TYPE
सिंटैक्स:
is_type(input: ANY, type: STRING) -> BOOLEAN
जानकारी:
अगर input, तय किए गए type से मैच करता है, तो true दिखाता है. ऐसा न होने पर, false दिखाता है.
अगर input मौजूद नहीं है, तो NULL दिखता है.
type की ये स्ट्रिंग इस्तेमाल की जा सकती हैं:
"null""boolean""int32""int64""float64""decimal128""number""timestamp""string""bytes""array""map""reference""vector""geo_point""max_key""min_key""object_id""regex""bson_timestamp"
प्रॉम्प्ट के उदाहरण:
input |
type |
is_type(input, type) |
|---|---|---|
| NULL | "null" | सही |
| सही | "boolean" | सही |
| 3.14 | "float64" | सही |
| "foo" | "स्ट्रिंग" | सही |
| b"foo" | "स्ट्रिंग" | गलत |
| [1, 2] | "array" | सही |
| "a": 1 | "मैप" | सही |
vector([1.0, 2.0]) |
"वेक्टर" | सही |
| अनुपस्थित | "स्ट्रिंग" | NULL |
| "bar" | "अन्य" | गड़बड़ी |
वेक्टर फ़ंक्शन
| नाम | ब्यौरा |
COSINE_DISTANCE
|
दो वेक्टर के बीच की कोसाइन दूरी दिखाता है |
DOT_PRODUCT
|
दो वेक्टर के बीच का डॉट प्रॉडक्ट दिखाता है |
EUCLIDEAN_DISTANCE
|
यह फ़ंक्शन, दो वेक्टर के बीच की यूक्लिडियन दूरी दिखाता है |
MANHATTAN_DISTANCE
|
दो वेक्टर के बीच की मैनहैटन दूरी दिखाता है |
VECTOR_LENGTH
|
यह किसी वेक्टर में मौजूद एलिमेंट की संख्या दिखाता है |
COSINE_DISTANCE
सिंटैक्स:
cosine_distance(x: VECTOR, y: VECTOR) -> FLOAT64
जानकारी:
x और y के बीच की कोसाइन दूरी दिखाता है.
Node.js
const sampleVector = [0.0, 1, 2, 3, 4, 5]; const result = await db.pipeline() .collection("books") .select( field("embedding").cosineDistance(sampleVector).as("cosineDistance") ) .execute();
Web
const sampleVector = [0.0, 1, 2, 3, 4, 5]; const result = await execute(db.pipeline() .collection("books") .select( field("embedding").cosineDistance(sampleVector).as("cosineDistance")));
Swift
let sampleVector = [0.0, 1, 2, 3, 4, 5] let result = try await db.pipeline() .collection("books") .select([ Field("embedding").cosineDistance(sampleVector).as("cosineDistance") ]) .execute()
Kotlin
val sampleVector = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0) val result = db.pipeline() .collection("books") .select( field("embedding").cosineDistance(sampleVector).alias("cosineDistance") ) .execute()
Java
double[] sampleVector = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("embedding").cosineDistance(sampleVector).alias("cosineDistance") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field from google.cloud.firestore_v1.vector import Vector sample_vector = Vector([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) result = ( client.pipeline() .collection("books") .select( Field.of("embedding").cosine_distance(sample_vector).as_("cosineDistance") ) .execute() )
Java
double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(cosineDistance(field("embedding"), sampleVector).as("cosineDistance")) .execute() .get();
जाएं
sampleVector := []float64{0.0, 1.0, 2.0, 3.0, 4.0, 5.0} snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.CosineDistance(firestore.FieldOf("embedding"), sampleVector).As("cosineDistance"), )). Execute(ctx)
DOT_PRODUCT
सिंटैक्स:
dot_product(x: VECTOR, y: VECTOR) -> FLOAT64
जानकारी:
x और y का डॉट प्रॉडक्ट दिखाता है.
Node.js
const sampleVector = [0.0, 1, 2, 3, 4, 5]; const result = await db.pipeline() .collection("books") .select( field("embedding").dotProduct(sampleVector).as("dotProduct") ) .execute();
Web
const sampleVector = [0.0, 1, 2, 3, 4, 5]; const result = await execute(db.pipeline() .collection("books") .select( field("embedding").dotProduct(sampleVector).as("dotProduct") ) );
Swift
let sampleVector = [0.0, 1, 2, 3, 4, 5] let result = try await db.pipeline() .collection("books") .select([ Field("embedding").dotProduct(sampleVector).as("dotProduct") ]) .execute()
Kotlin
val sampleVector = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0) val result = db.pipeline() .collection("books") .select( field("embedding").dotProduct(sampleVector).alias("dotProduct") ) .execute()
Java
double[] sampleVector = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("embedding").dotProduct(sampleVector).alias("dotProduct") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field from google.cloud.firestore_v1.vector import Vector sample_vector = Vector([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) result = ( client.pipeline() .collection("books") .select(Field.of("embedding").dot_product(sample_vector).as_("dotProduct")) .execute() )
Java
double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(dotProduct(field("embedding"), sampleVector).as("dotProduct")) .execute() .get();
जाएं
sampleVector := []float64{0.0, 1.0, 2.0, 3.0, 4.0, 5.0} snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.DotProduct(firestore.FieldOf("embedding"), sampleVector).As("dotProduct"), )). Execute(ctx)
EUCLIDEAN_DISTANCE
सिंटैक्स:
euclidean_distance(x: VECTOR, y: VECTOR) -> FLOAT64
जानकारी:
यह x और y के बीच की यूक्लिडियन दूरी की गणना करता है.
Node.js
const sampleVector = [0.0, 1, 2, 3, 4, 5]; const result = await db.pipeline() .collection("books") .select( field("embedding").euclideanDistance(sampleVector).as("euclideanDistance") ) .execute();
Web
const sampleVector = [0.0, 1, 2, 3, 4, 5]; const result = await execute(db.pipeline() .collection("books") .select( field("embedding").euclideanDistance(sampleVector).as("euclideanDistance") ) );
Swift
let sampleVector = [0.0, 1, 2, 3, 4, 5] let result = try await db.pipeline() .collection("books") .select([ Field("embedding").euclideanDistance(sampleVector).as("euclideanDistance") ]) .execute()
Kotlin
val sampleVector = doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0) val result = db.pipeline() .collection("books") .select( field("embedding").euclideanDistance(sampleVector).alias("euclideanDistance") ) .execute()
Java
double[] sampleVector = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("embedding").euclideanDistance(sampleVector).alias("euclideanDistance") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field from google.cloud.firestore_v1.vector import Vector sample_vector = Vector([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) result = ( client.pipeline() .collection("books") .select( Field.of("embedding") .euclidean_distance(sample_vector) .as_("euclideanDistance") ) .execute() )
Java
double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(euclideanDistance(field("embedding"), sampleVector).as("euclideanDistance")) .execute() .get();
जाएं
sampleVector := []float64{0.0, 1.0, 2.0, 3.0, 4.0, 5.0} snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.EuclideanDistance(firestore.FieldOf("embedding"), sampleVector).As("euclideanDistance"), )). Execute(ctx)
MANHATTAN_DISTANCE
सिंटैक्स:
manhattan_distance(x: VECTOR, y: VECTOR) -> FLOAT64
जानकारी:
x और y के बीच की मैनहैटन दूरी की गणना करता है.
VECTOR_LENGTH
सिंटैक्स:
vector_length(vector: VECTOR) -> INT64
जानकारी:
यह फ़ंक्शन, VECTOR में मौजूद एलिमेंट की संख्या दिखाता है.
Node.js
const result = await db.pipeline() .collection("books") .select( field("embedding").vectorLength().as("vectorLength") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("embedding").vectorLength().as("vectorLength") ) );
Swift
let result = try await db.pipeline() .collection("books") .select([ Field("embedding").vectorLength().as("vectorLength") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("embedding").vectorLength().alias("vectorLength") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("embedding").vectorLength().alias("vectorLength") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("embedding").vector_length().as_("vectorLength")) .execute() )
Java
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(vectorLength(field("embedding")).as("vectorLength")) .execute() .get();
जाएं
snapshot := client.Pipeline(). Collection("books"). Select(firestore.Fields( firestore.VectorLength(firestore.FieldOf("embedding")).As("vectorLength"), )). Execute(ctx)