সমষ্টি
সমস্ত অ্যাগ্রিগেট ফাংশন ` 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() -> INT64
count(expression: ANY) -> INT64
বর্ণনা:
পূর্ববর্তী ধাপের সেইসব ডকুমেন্টের সংখ্যা ফেরত দেয়, যেখানে expression মান যেকোনো নন- NULL ভ্যালু হয়। যদি কোনো expression প্রদান করা না হয়, তবে পূর্ববর্তী ধাপের ডকুমেন্টগুলোর মোট সংখ্যা ফেরত দেওয়া হয়।
নোড.জেএস
// 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")) );
সুইফট
// 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();
পাইথন
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() )
জাভা
// 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();
COUNT_IF
সিনট্যাক্স:
count_if(expression: BOOLEAN) -> INT64
বর্ণনা:
পূর্ববর্তী ধাপের সেইসব ডকুমেন্টের সংখ্যা ফেরত দেয় যেখানে expression মান TRUE হয়।
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .aggregate([ AggregateFunction("count_if", [Field("rating").greaterThan(4)]).as("filteredCount") ]) .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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(countIf(field("rating").greaterThan(4)).as("filteredCount")) .execute() .get();
COUNT_DISTINCT
সিনট্যাক্স:
count_distinct(expression: ANY) -> INT64
বর্ণনা:
expression অনন্য, নন- NULL ও নন- ABSENT মানগুলোর সংখ্যা ফেরত দেয়।
নোড.জেএস
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")) );
সুইফট
let result = try await db.pipeline() .collection("books") .aggregate([AggregateFunction("count_distinct", [Field("author")]).as("unique_authors")]) .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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("author").count_distinct().as_("unique_authors")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(countDistinct("author").as("unique_authors")) .execute() .get();
যোগফল
সিনট্যাক্স:
sum(expression: ANY) -> NUMBER
বর্ণনা:
অ-সংখ্যাসূচক মান উপেক্ষা করে সমস্ত সংখ্যাসূচক মানের যোগফল ফেরত দেয়। যদি কোনো মান NaN হয়, তবে NaN ফেরত দেয়।
নিম্নলিখিত ক্ষেত্রগুলি ব্যতীত, আউটপুটের ধরণ প্রশস্ততম ইনপুট ধরণের মতোই হবে:
- যদি কোনো
INTEGERINTEGERহিসেবে প্রকাশ করা না যায়, তবে সেটিকেDOUBLEএ রূপান্তর করা হবে।
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("cities") .aggregate(Field.of("population").sum().as_("totalPopulation")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("cities") .aggregate(sum("population").as("totalPopulation")) .execute() .get();
গড়
সিনট্যাক্স:
average(expression: ANY) -> FLOAT64
বর্ণনা:
অ-সংখ্যাসূচক মান উপেক্ষা করে সমস্ত সংখ্যাসূচক মানের গড় ফেরত দেয়। যদি কোনো মান NaN হয়, তবে এর মান NaN হয়, অথবা যদি কোনো সংখ্যাসূচক মানের যোগফল বের না করা হয়, তবে এর মান NULL ।
নিম্নলিখিত ক্ষেত্রগুলি ব্যতীত আউটপুটের ধরণ ইনপুটের ধরনের মতোই হবে:
- যদি কোনো
INTEGERINTEGERহিসেবে প্রকাশ করা না যায়, তবে সেটিকেDOUBLEএ রূপান্তর করা হবে।
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("cities") .aggregate(Field.of("population").average().as_("averagePopulation")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("cities") .aggregate(average("population").as("averagePopulation")) .execute() .get();
সর্বনিম্ন
সিনট্যাক্স:
minimum(expression: ANY) -> ANY
বর্ণনা:
প্রতিটি ডকুমেন্টের উপর মূল্যায়ন করার পর expression সর্বনিম্ন নন-নাল ( NULL ও নন-অ্যাবসেন্ট (absent) মান ফেরত দেয়।
যদি NULL নয় এমন বা অনুপস্থিত নয় এমন কোনো মান না থাকে, তাহলে NULL রিটার্ন করা হয়। কোনো ডকুমেন্ট বিবেচনা না করা হলেও এটি প্রযোজ্য।
যদি একাধিক সর্বনিম্ন সমতুল্য মান থাকে, তবে সেই মানগুলোর যেকোনো একটি ফেরত দেওয়া যেতে পারে। মানের প্রকারের ক্রম নথিভুক্ত ক্রম অনুসরণ করে।
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("price").minimum().as_("minimumPrice")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(minimum("price").as("minimumPrice")) .execute() .get();
সর্বোচ্চ
সিনট্যাক্স:
maximum(expression: ANY) -> ANY
বর্ণনা:
প্রতিটি ডকুমেন্টের উপর মূল্যায়ন করার পর expression সর্বোচ্চ নন-নাল ( NULL ও নন-অ্যাবসেন্ট (absent) মান ফেরত দেয়।
যদি NULL নয় এমন বা অনুপস্থিত নয় এমন কোনো মান না থাকে, তাহলে NULL রিটার্ন করা হয়। কোনো ডকুমেন্ট বিবেচনা না করা হলেও এটি প্রযোজ্য।
যদি একাধিক সর্বোচ্চ সমতুল্য মান থাকে, তবে সেই মানগুলোর যেকোনো একটি ফেরত দেওয়া যেতে পারে। মানের প্রকারের ক্রম নথিভুক্ত ক্রম অনুসরণ করে।
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .aggregate(Field.of("price").maximum().as_("maximumPrice")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .aggregate(maximum("price").as("maximumPrice")) .execute() .get();
প্রথম
সিনট্যাক্স:
first(expression: ANY) -> ANY
বর্ণনা:
প্রথম ফেরত আসা ডকুমেন্টটির জন্য expression মান প্রদান করে।
শেষ
সিনট্যাক্স:
last(expression: ANY) -> ANY
বর্ণনা:
সর্বশেষ ফেরত আসা ডকুমেন্টের expression মান প্রদান করে।
অ্যারে_এজিজি
সিনট্যাক্স:
array_agg(expression: ANY) -> ARRAY<ANY>
বর্ণনা:
প্রতিটি ডকুমেন্টে মূল্যায়ন করার পর expression সমস্ত মান ধারণকারী একটি অ্যারে ফেরত দেয়।
যদি এক্সপ্রেশনটির মান অনুপস্থিত থাকে, তবে সেটিকে NULL এ রূপান্তর করা হয়।
আউটপুট অ্যারের উপাদানগুলোর ক্রম স্থিতিশীল নয় এবং এর ওপর নির্ভর করা উচিত নয়।
অ্যারে_এজিজি_ডিস্টিংক্ট
সিনট্যাক্স:
array_agg_distinct(expression: ANY) -> ARRAY<ANY>
বর্ণনা:
প্রতিটি ডকুমেন্টে মূল্যায়ন করার পর expression সমস্ত স্বতন্ত্র মান ধারণকারী একটি অ্যারে ফেরত দেয়।
যদি এক্সপ্রেশনটির মান অনুপস্থিত থাকে, তবে সেটিকে NULL এ রূপান্তর করা হয়।
আউটপুট অ্যারের উপাদানগুলোর ক্রম স্থিতিশীল নয় এবং এর ওপর নির্ভর করা উচিত নয়।
গাণিতিক ফাংশন
Cloud Firestore সমস্ত গাণিতিক ফাংশনের নিম্নলিখিত আচরণগুলো রয়েছে:
- ইনপুট প্যারামিটারগুলোর কোনো একটি
NULLহলে এর মানওNULL। - যদি আর্গুমেন্টগুলোর কোনো একটি
NaNহয়, তাহলে এর মানওNaNহবে। - ওভারফ্লো বা আন্ডারফ্লো ঘটলে একটি ত্রুটি বার্তা তৈরি হয়।
এছাড়াও, যখন কোনো গাণিতিক ফাংশন বিভিন্ন ধরনের একাধিক সাংখ্যিক আর্গুমেন্ট গ্রহণ করে (উদাহরণস্বরূপ: add(5.0, 6) ), তখন Cloud Firestore স্বয়ংক্রিয়ভাবে আর্গুমেন্টগুলোকে সবচেয়ে প্রশস্ত ইনপুট টাইপে রূপান্তর করে। যদি শুধুমাত্র INT32 ইনপুট প্রদান করা হয়, তাহলে রিটার্ন টাইপ হবে INT64 ।
| নাম | বর্ণনা |
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 | কোনো number 10 ভিত্তিক লগারিদম নির্ণয় করে। |
RAND | একটি ছদ্ম-এলোমেলো ফ্লোটিং পয়েন্ট সংখ্যা ফেরত দেয় |
এবিএস
সিনট্যাক্স:
abs[N <: INT32 | INT64 | FLOAT64](number: N) -> N
বর্ণনা:
কোনো number পরম মান ফেরত দেয়।
- ফাংশনটি
INT32বাINT64মান ওভারফ্লো করলে একটি ত্রুটি দেখায়।
উদাহরণ:
| সংখ্যা | abs(number) |
|---|---|
| ১০ | ১০ |
| -১০ | ১০ |
| ১০ লিটার | ১০ লিটার |
| -০.০ | ০.০ |
| ১০.৫ | ১০.৫ |
| -১০.৫ | ১০.৫ |
| -২ ৩১ | [error] |
| -২ ৬৩ | [error] |
যোগ করুন
সিনট্যাক্স:
add[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
বর্ণনা:
x + y এর মান ফেরত দেয়।
উদাহরণ:
| x | y | add(x, y) |
|---|---|---|
| ২০ | ৩ | ২৩ |
| ১০.০ | ১ | ১১.০ |
| ২২.৫ | ২.০ | ২৪.৫ |
| INT64.MAX | ১ | [error] |
| INT64.MIN | -১ | [error] |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(add(field("soldBooks"), field("unsoldBooks")).as("totalBooks")) .execute() .get();
বিয়োগ
সিনট্যাক্স:
subtract[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
বর্ণনা:
x - y এর মান ফেরত দেয়।
উদাহরণ:
| x | y | subtract(x, y) |
|---|---|---|
| ২০ | ৩ | ১৭ |
| ১০.০ | ১ | ৯.০ |
| ২২.৫ | ২.০ | ২০.৫ |
| INT64.MAX | -১ | [error] |
| INT64.MIN | ১ | [error] |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
int storeCredit = 7; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(subtract(field("price"), storeCredit).as("totalCost")) .execute() .get();
গুণ করুন
সিনট্যাক্স:
multiply[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
বর্ণনা:
x * y এর মান ফেরত দেয়।
উদাহরণ:
| x | y | multiply(x, y) |
|---|---|---|
| ২০ | ৩ | ৬০ |
| ১০.০ | ১ | ১০.০ |
| ২২.৫ | ২.০ | ৪৫.০ |
| INT64.MAX | ২ | [error] |
| INT64.MIN | ২ | [error] |
| ফ্লোট৬৪.ম্যাক্স | ফ্লোট৬৪.ম্যাক্স | +inf |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(multiply(field("price"), field("soldBooks")).as("revenue")) .execute() .get();
ভাগ করুন
সিনট্যাক্স:
divide[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
বর্ণনা:
x / y এর মান ফেরত দেয়। পূর্ণসংখ্যার ভাগফল সংক্ষিপ্ত করা হয়।
উদাহরণ:
| x | y | divide(x, y) |
|---|---|---|
| ২০ | ৩ | ৬ |
| ১০.০ | ৩ | ৩.৩৩৩... |
| ২২.৫ | ২ | ১১.২৫ |
| ১০ | ০ | [error] |
| ১.০ | ০.০ | +inf |
| -১.০ | ০.০ | -inf |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(divide(field("ratings"), field("soldBooks")).as("reviewRate")) .execute() .get();
মোড
সিনট্যাক্স:
mod[N <: INT32 | INT64 | FLOAT64](x: N, y: N) -> N
বর্ণনা:
x / y এর ভাগশেষ ফেরত দেয়।
- পূর্ণসংখ্যা টাইপের (
INT64) ক্ষেত্রেyএর মান শূন্য হলে একটিerrorদেখায়। - ফ্লোট টাইপের (
FLOAT64) ক্ষেত্রেyএর মান শূন্য হলেNaNরিটার্ন করে।
উদাহরণ:
| x | y | mod(x, y) |
|---|---|---|
| ২০ | ৩ | ২ |
| -১০ | ৩ | -১ |
| ১০ | -৩ | ১ |
| -১০ | -৩ | -১ |
| ১০ | ১ | ০ |
| ২২.৫ | ২ | ০.৫ |
| ২২.৫ | ০.০ | NaN |
| ২৫ | ০ | [error] |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
int displayCapacity = 1000; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(mod(field("unsoldBooks"), displayCapacity).as("warehousedBooks")) .execute() .get();
সিইআইএল
সিনট্যাক্স:
ceil[N <: INT32 | INT64 | FLOAT64](number: N) -> N
বর্ণনা:
সর্বনিম্ন পূর্ণসংখ্যা মান ফেরত দেয় যা number এর চেয়ে ছোট নয়।
উদাহরণ:
| সংখ্যা | ceil(number) |
|---|---|
| ২০ | ২০ |
| ১০ | ১০ |
| ০ | ০ |
| ২৪ লিটার | ২৪ লিটার |
| -০.৪ | -০.০ |
| ০.৪ | ১.০ |
| ২২.৫ | ২৩.০ |
+inf | +inf |
-inf | -inf |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
int booksPerShelf = 100; Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(ceil(divide(field("unsoldBooks"), booksPerShelf)).as("requiredShelves")) .execute() .get();
মেঝে
সিনট্যাক্স:
floor[N <: INT32 | INT64 | FLOAT64](number: N) -> N
বর্ণনা:
এমন বৃহত্তম পূর্ণসংখ্যাটি ফেরত দেয় যা number চেয়ে বড় নয়।
উদাহরণ:
| সংখ্যা | floor(number) |
|---|---|
| ২০ | ২০ |
| ১০ | ১০ |
| ০ | ০ |
| ২১৪৭৪৮৩৬৪৮ | ২১৪৭৪৮৩৬৪৮ |
| -০.৪ | -১.০ |
| ০.৪ | ০.০ |
| ২২.৫ | ২২.০ |
+inf | +inf |
-inf | -inf |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .addFields(floor(divide(field("wordCount"), field("pages"))).as("wordsPerPage")) .execute() .get();
রাউন্ড
সিনট্যাক্স:
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) |
|---|---|---|
| ১৫.৫ | ০ | ১৬.০ |
| -১৫.৫ | ০ | -১৬.০ |
| ১৫ | ১ | ১৫ |
| ১৫ | ০ | ১৫ |
| ১৫ | -১ | ২০ |
| ১৫ | -২ | ০ |
| ১৫.৪৮৯২৪ | ১ | ১৫.৫ |
| ২ ৩১ -১ | -১ | [error] |
| ২ ৬৩ -১ লিটার | -১ | [error] |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(round(multiply(field("soldBooks"), field("price"))).as("partialRevenue")) .aggregate(sum("partialRevenue").as("totalRevenue")) .execute() .get();
ট্রাঙ্ক
সিনট্যাক্স:
trunc[N <: Number](number: N) -> N
trunc[N <: Number](number: N, places: INT64) -> N
বর্ণনা:
একটি number নির্দিষ্ট সংখ্যক দশমিক places পর্যন্ত ছেঁটে ফেলে। দশমিক বিন্দুর places ধনাত্মক হলে ডান দিক থেকে এবং ঋণাত্মক হলে বাম দিক থেকে অঙ্কগুলো ছেঁটে ফেলা হয়।
- শুধুমাত্র
numberপ্রদান করা হলে, শূন্যের দিকে নিকটতম পূর্ণ সংখ্যায় ছেঁটে ফেলা হয়। - ট্রাঙ্কেট করার ফলে ওভারফ্লো হলে একটি
errorদেখানো হয়।
উদাহরণ:
| সংখ্যা | স্থান | trunc(number, places) |
|---|---|---|
| ১৫.৫ | ০ | ১৫.০ |
| -১৫.৫ | ০ | -১৫.০ |
| ১৫ | ১ | ১৫ |
| ১৫ | ০ | ১৫ |
| ১৫ | -১ | ১০ |
| ১৫ | -২ | ০ |
| ১৫.৪৮৯২৪ | ১ | ১৫.৪ |
| -১৫.৪৮৯২৪ | ২ | -১৫.৪৮ |
যুদ্ধবন্দী
সিনট্যাক্স:
pow(base: FLOAT64, exponent: FLOAT64) -> FLOAT64
বর্ণনা:
base মানটিকে exponent ঘাতে উন্নীত করে ফেরত দেয়।
base <= 0এবংexponentঋণাত্মক হলে একটি ত্রুটি দেখায়।যেকোনো
exponentজন্য,pow(1, exponent)মান 1 হয়।যেকোনো
baseজন্য,pow(base, 0)-এর মান 1।
উদাহরণ:
| ভিত্তি | সূচক | pow(base, exponent) |
|---|---|---|
| ২ | ৩ | ৮.০ |
| ২ | -৩ | ০.১২৫ |
+inf | ০ | ১.০ |
| ১ | +inf | ১.০ |
| -১ | ০.৫ | [error] |
| ০ | -১ | [error] |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
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();
বর্গমূল
সিনট্যাক্স:
sqrt[N <: FLOAT64 | DECIMAL128](number: N) -> N
বর্ণনা:
কোনো number বর্গমূল ফেরত দেয়।
-
numberঋণাত্মক হলে একটিerrorদেখায়।
উদাহরণ:
| সংখ্যা | sqrt(number) |
|---|---|
| ২৫ | ৫.০ |
| ১২.০০২ | ৩.৪৬৪... |
| ০.০ | ০.০ |
NaN | NaN |
+inf | +inf |
-inf | [error] |
x < 0 | [error] |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
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();
EXP
সিনট্যাক্স:
exp(exponent: FLOAT64) -> FLOAT64
বর্ণনা:
এটি ইউলার সংখ্যার exponent মান ফেরত দেয়, যাকে স্বাভাবিক সূচকীয় ফাংশনও বলা হয়।
উদাহরণ:
| সূচক | exp(exponent) |
|---|---|
| ০.০ | ১.০ |
| ১০ | e^10 ( FLOAT64 ) |
+inf | +inf |
-inf | ০ |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").exp().as_("expRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(exp(field("rating")).as("expRating")) .execute() .get();
এলএন
সিনট্যাক্স:
ln(number: FLOAT64) -> FLOAT64
বর্ণনা:
এই ফাংশনটি number এর স্বাভাবিক লগারিদম ফেরত দেয়। এই ফাংশনটি log(number) এর সমতুল্য।
উদাহরণ:
| সংখ্যা | ln(number) |
|---|---|
| ১ | ০.০ |
| ২ লিটার | ০.৬৯৩... |
| ১.০ | ০.০ |
e ( FLOAT64 ) | ১.০ |
-inf | NaN |
+inf | +inf |
x <= 0 | [error] |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").ln().as_("lnRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(ln(field("rating")).as("lnRating")) .execute() .get();
লগ
সিনট্যাক্স:
log(number: FLOAT64, base: FLOAT64) -> FLOAT64
log(number: FLOAT64) -> FLOAT64
বর্ণনা:
কোনো number লগারিদম base মান হিসেবে ফেরত দেয়।
- যদি শুধু
numberদেওয়া হয়, তাহলেnumberbaseএর সাপেক্ষে লগারিদম ফেরত দেওয়া হয় (যাln(number)-এর সমতুল্য)।
উদাহরণ:
| সংখ্যা | ভিত্তি | log(number, base) |
|---|---|---|
| ১০০ | ১০ | ২.০ |
-inf | Numeric | NaN |
Numeric । | +inf | NaN |
number <= 0 | Numeric | [error] |
Numeric | base <= 0 | [error] |
Numeric | ১.০ | [error] |
লগ১০
সিনট্যাক্স:
log10(x: FLOAT64) -> FLOAT64
বর্ণনা:
কোনো number 10 ভিত্তিক লগারিদম নির্ণয় করে।
উদাহরণ:
| সংখ্যা | log10(number) |
|---|---|
| ১০০ | ২.০ |
-inf | NaN |
+inf | +inf |
x <= 0 | [error] |
র্যান্ড
সিনট্যাক্স:
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(values: ANY...) -> ARRAY
বর্ণনা:
প্রদত্ত উপাদানগুলো থেকে একটি অ্যারে গঠন করে।
- যদি কোনো আর্গুমেন্ট বিদ্যমান না থাকে, তাহলে ফলাফল অ্যারেতে সেটিকে
NULLদ্বারা প্রতিস্থাপন করা হয়।
উদাহরণ:
| মূল্যবোধ | array(values) |
|---|---|
| () | [] |
| (১, ২, ৩) | [১, ২, ৩] |
| ("a", 1, সত্য) | ["a", 1, সত্য] |
| (১, শূন্য) | [১, শূন্য] |
| (১, [২, ৩]) | [1, [2, 3]] |
অ্যারে_কনক্যাট
সিনট্যাক্স:
array_concat(arrays: ARRAY...) -> ARRAY
বর্ণনা:
দুই বা ততোধিক অ্যারে একত্রিত করে একটি একক ARRAY তৈরি করে।
উদাহরণ:
| অ্যারে | array_concat(arrays) |
|---|---|
| ([1, 2], [3, 4]) | [১, ২, ৩, ৪] |
| (["ক", "খ"], ["গ"]) | ["a", "b", "c"] |
| ([1], [2], [3]) | [১, ২, ৩] |
| ([], [1, 2]) | [১, ২] |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select(field("genre").arrayConcat([field("subGenre")]).as("allGenres")) .execute();
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayConcat(field("genre"), field("subGenre")).as("allGenres")) .execute() .get();
অ্যারেতে রয়েছে
সিনট্যাক্স:
array_contains(array: ARRAY, value: ANY) -> BOOLEAN
বর্ণনা:
array value পাওয়া গেলে TRUE , অন্যথায় FALSE রিটার্ন করে।
উদাহরণ:
| অ্যারে | মূল্য | array_contains(array, value) |
|---|---|---|
| [১, ২, ৩] | ২ | সত্য |
| [[1, 2], [3]] | [১, ২] | সত্য |
| [১, শূন্য] | নাল | সত্য |
| "এবিসি" | যেকোনো | ত্রুটি |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_contains("mystery").as_("isMystery")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayContains(field("genre"), "mystery").as("isMystery")) .execute() .get();
অ্যারেতে সবকিছু রয়েছে
সিনট্যাক্স:
array_contains_all(array: ARRAY, search_values: ARRAY) -> BOOLEAN
বর্ণনা:
array সমস্ত search_values পাওয়া গেলে TRUE রিটার্ন করে, অন্যথায় FALSE রিটার্ন করে।
উদাহরণ:
| অ্যারে | অনুসন্ধানের মান | array_contains_all(array, search_values) |
|---|---|---|
| [১, ২, ৩] | [১, ২] | সত্য |
| [১, ২, ৩] | [১, ৪] | মিথ্যা |
| [১, শূন্য] | [null] | সত্য |
| [NaN] | [NaN] | সত্য |
| [] | [] | সত্য |
| [১, ২, ৩] | [] | সত্য |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayContainsAll(field("genre"), Arrays.asList("fantasy", "adventure")) .as("isFantasyAdventure")) .execute() .get();
অ্যারেতে যেকোনো কিছু রয়েছে
সিনট্যাক্স:
array_contains_any(array: ARRAY, search_values: ARRAY) -> BOOLEAN
বর্ণনা:
array search_values গুলোর কোনোটি পাওয়া গেলে TRUE রিটার্ন করে, অন্যথায় FALSE রিটার্ন করে।
উদাহরণ:
| অ্যারে | অনুসন্ধানের মান | array_contains_any(array, search_values) |
|---|---|---|
| [১, ২, ৩] | [৪, ১] | সত্য |
| [১, ২, ৩] | [৪, ৫] | মিথ্যা |
| [১, ২, শূন্য] | [null] | সত্য |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayContainsAny(field("genre"), Arrays.asList("fantasy", "nonfiction")) .as("isMysteryOrFantasy")) .execute() .get();
অ্যারে_ফিল্টার
সিনট্যাক্স:
array_filter(array: ARRAY, predicate: (ANY) -> BOOLEAN) -> ARRAY
বর্ণনা:
একটি predicate এক্সপ্রেশন ব্যবহার করে array ফিল্টার করে এবং শুধুমাত্র প্রেডিকেটটি পূরণকারী উপাদানগুলো নিয়ে একটি নতুন অ্যারে ফেরত দেয়।
-
arrayপ্রতিটি উপাদানের জন্যpredicateমূল্যায়ন করা হয়। যদি এটিtrueরিটার্ন করে, তাহলে উপাদানটি ফলাফলে অন্তর্ভুক্ত করা হয়; অন্যথায় (যদি এটিfalseবাnull' রিটার্ন করে), তবে তা বাদ দেওয়া হয়। - যদি
predicateমান বুলিয়ান বা নাল নয় এমন কোনো মানে পরিবর্তিত হয়, তাহলে ফাংশনটি একটি এরর রিটার্ন করে।
উদাহরণ:
| অ্যারে | বিধেয় | array_filter(array, predicate) |
|---|---|---|
| [১, ২, ৩] | x -> x > 1 | [২, ৩] |
| [১, শূন্য, ৩] | x -> x > 1 | [3] |
| ["a", "b", "c"] | x -> x != "b" | ["ক", "গ"] |
| [] | x -> সত্য | [] |
অ্যারে_গেট
সিনট্যাক্স:
array_get(array: ARRAY, index: INT64) -> ANY
বর্ণনা:
array ০-ভিত্তিক index থাকা এলিমেন্টটি রিটার্ন করে।
-
indexঋণাত্মক হলে, অ্যারের শেষ থেকে এলিমেন্টগুলো অ্যাক্সেস করা হয়, যেখানে-1হলো শেষ এলিমেন্ট। -
arrayARRAYটাইপের না হলে এবংnullনা হলে, একটি ত্রুটি ফেরত দেওয়া হয়। -
indexসীমার বাইরে থাকলে, ফাংশনটি একটি অনুপস্থিত মান ফেরত দেয়। - যদি
indexINT64টাইপের না হয়, তাহলে ফাংশনটি একটি ত্রুটি ফেরত দেয়।
উদাহরণ:
| অ্যারে | সূচক | array_get(array, index) |
|---|---|---|
| [১, ২, ৩] | ০ | ১ |
| [১, ২, ৩] | -১ | ৩ |
| [১, ২, ৩] | ৩ | অনুপস্থিত |
| [১, ২, ৩] | -৪ | অনুপস্থিত |
| "এবিসি" | ০ | ত্রুটি |
| নাল | ০ | নাল |
Array | "ক" | ত্রুটি |
Array | ২.০ | ত্রুটি |
অ্যারের দৈর্ঘ্য
সিনট্যাক্স:
array_length(array: ARRAY) -> INT64
বর্ণনা:
array থাকা উপাদানের সংখ্যা ফেরত দেয়।
উদাহরণ:
| অ্যারে | array_length(array) |
|---|---|
| [১, ২, ৩] | ৩ |
| [] | ০ |
| [১, ১, ১] | ৩ |
| [১, শূন্য] | ২ |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_length().as_("genreCount")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayLength(field("genre")).as("genreCount")) .execute() .get();
অ্যারে_রিভার্স
সিনট্যাক্স:
array_reverse(array: ARRAY) -> ARRAY
বর্ণনা:
প্রদত্ত array উল্টে দেয়।
উদাহরণ:
| অ্যারে | array_reverse(array) |
|---|---|
| [১, ২, ৩] | [৩, ২, ১] |
| ["ক", "খ"] | ["b", "a"] |
| [১, ২, ২, ৩] | [৩, ২, ২, ১] |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").array_reverse().as_("reversedGenres")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(arrayReverse(field("genre")).as("reversedGenres")) .execute() .get();
অ্যারে_প্রথম
সিনট্যাক্স:
array_first(array: ARRAY) -> ANY
বর্ণনা:
array প্রথম উপাদানটি ফেরত দেয়। এটি array_get(array, 0) এর সমতুল্য।
-
arrayখালি থাকলে, অনুপস্থিত মানটি ফেরত দেওয়া হয়।
উদাহরণ:
| অ্যারে | array_first(array) |
|---|---|
| [১, ২, ৩] | ১ |
| [] | অনুপস্থিত |
অ্যারে_ফার্স্ট_এন
সিনট্যাক্স:
array_first_n(array: ARRAY, n: INT64) -> ARRAY
বর্ণনা:
array প্রথম n উপাদান ফেরত দেয়। এটি array_slice(array, 0, n) এর সমতুল্য।
-
nঋণাত্মক হলে, একটি ত্রুটি দেখানো হয়।
উদাহরণ:
| অ্যারে | এন | array_first_n(array, n) |
|---|---|---|
| [১, ২, ৩, ৪, ৫] | ৩ | [১, ২, ৩] |
| [১, ২] | ৩ | [১, ২] |
| [১, ২, ৩] | ০ | [] |
অ্যারে_সূচক_অফ
সিনট্যাক্স:
array_index_of(array: ARRAY, value: ANY) -> INT64
বর্ণনা:
array value এর প্রথম উপস্থিতির ০-ভিত্তিক সূচকটি ফেরত দেয়। value খুঁজে না পাওয়া গেলে -১ ফেরত দেয়।
উদাহরণ:
| অ্যারে | মূল্য | array_index_of(array, value) |
|---|---|---|
| [১, ২, ৩, ২] | ২ | ১ |
| [১, ২, ৩] | ৪ | -১ |
| [১, শূন্য, ৩] | নাল | ১ |
ARRAY_INDEX_OF_ALL
সিনট্যাক্স:
array_index_of_all(array: ARRAY, value: ANY) -> ARRAY<INT64>
বর্ণনা:
array তে value এর সমস্ত উপস্থিতির ০-ভিত্তিক সূচক ধারণকারী একটি অ্যারে ফেরত দেয়। value খুঁজে না পাওয়া গেলে [] ফেরত দেয়।
উদাহরণ:
| অ্যারে | মূল্য | array_index_of_all(array, value) |
|---|---|---|
| [১, ২, ৩, ২] | ২ | [১, ৩] |
| [১, ২, ৩] | ৪ | [] |
| [১, শূন্য, ৩, শূন্য] | নাল | [১, ৩] |
অ্যারে_শেষ
সিনট্যাক্স:
array_last(array: ARRAY) -> ANY
বর্ণনা:
array সর্বশেষ উপাদানটি ফেরত দেয়। এটি array_get(array, -1) এর সমতুল্য।
-
arrayখালি থাকলে, অনুপস্থিত মানটি ফেরত দেওয়া হয়।
উদাহরণ:
| অ্যারে | array_last(array) |
|---|---|
| [১, ২, ৩] | ৩ |
| [] | অনুপস্থিত |
অ্যারে_শেষ_এন
সিনট্যাক্স:
array_last_n(array: ARRAY, n: INT64) -> ARRAY
বর্ণনা:
array শেষ n উপাদান ফেরত দেয়।
-
nঋণাত্মক হলে, একটি ত্রুটি দেখানো হয়।
উদাহরণ:
| অ্যারে | এন | array_last_n(array, n) |
|---|---|---|
| [১, ২, ৩, ৪, ৫] | ৩ | [৩, ৪, ৫] |
| [১, ২] | ৩ | [১, ২] |
| [১, ২, ৩] | ০ | [] |
অ্যারে_স্লাইস
সিনট্যাক্স:
array_slice(array: ARRAY, offset: INT64, length: INT64) -> ARRAY
বর্ণনা:
০-ভিত্তিক ইনডেক্স offset থেকে শুরু করে এবং length উপাদান অন্তর্ভুক্ত একটি array উপসেট ফেরত দেয়।
-
offsetঋণাত্মক হলে, তা অ্যারের শেষ থেকে শুরুর অবস্থান নির্দেশ করে, যেখানে-1হলো শেষ উপাদান। - যদি
lengthoffsetপরে অ্যারেতে অবশিষ্ট থাকা উপাদানের সংখ্যার চেয়ে বেশি হয়, তাহলে ফলাফলটি অ্যারের শেষ পর্যন্ত বিস্তৃত হয়। -
lengthঅবশ্যই অঋণাত্মক হতে হবে, অন্যথায় একটি ত্রুটি প্রদর্শিত হবে।
উদাহরণ:
| অ্যারে | অফসেট | দৈর্ঘ্য | array_slice(array, offset, length) |
|---|---|---|---|
| [১, ২, ৩, ৪, ৫] | ১ | ৩ | [২, ৩, ৪] |
| [১, ২, ৩, ৪, ৫] | -২ | ২ | [৪, ৫] |
| [১, ২, ৩] | ১ | ৫ | [২, ৩] |
| [১, ২, ৩] | ৩ | ২ | [] |
অ্যারে_ট্রান্সফর্ম
সিনট্যাক্স:
array_transform(array: ARRAY, expression: (ANY) -> ANY) -> ARRAY
array_transform(array: ARRAY, expression: (ANY, INT64) -> ANY) -> ARRAY
বর্ণনা:
প্রতিটি উপাদানে expression প্রয়োগ করে array রূপান্তরিত করে এবং রূপান্তরিত উপাদানগুলোসহ একটি নতুন অ্যারে ফেরত দেয়। আউটপুট অ্যারের আকার সর্বদা ইনপুট অ্যারের আকারের সমান হবে।
-
expressionএকটি ইউনারি ফাংশনelement -> result, অথবা একটি বাইনারি ফাংশন(element, index) -> resultহতে পারে। -
expressionইউনারি হলে, এটিকেarrayপ্রতিটি উপাদানের সাথে কল করা হয়। -
expressionবাইনারি হলে,arrayপ্রতিটি উপাদান এবং তার সংশ্লিষ্ট ০-ভিত্তিক ইনডেক্স দিয়ে এটিকে কল করা হয়।
উদাহরণ:
| অ্যারে | অভিব্যক্তি | array_transform(array, expression) |
|---|---|---|
| [১, ২, ৩] | x -> x * 2 | [২, ৪, ৬] |
| [১, ২, ৩] | x -> x + 1 | [২, ৩, ৪] |
| [১০, ২০] | (x, i) -> x + i | [১০, ২১] |
| [] | x -> 1 | [] |
সর্বোচ্চ
সিনট্যাক্স:
maximum(array: ARRAY) -> ANY
বর্ণনা:
array সর্বোচ্চ মানটি ফেরত দেয়।
- তুলনা করার সময়
NULLমান উপেক্ষা করা হয়। -
arrayখালি থাকলে বা এতে শুধুমাত্রNULLমান থাকলে,NULLরিটার্ন করা হয়।
উদাহরণ:
| অ্যারে | maximum(array) |
|---|---|
| [১, ৫, ২] | ৫ |
| [১, শূন্য, ৫] | ৫ |
| ["a", "c", "b"] | "গ" |
| [শূন্য, শূন্য] | নাল |
| [] | নাল |
সর্বোচ্চ_N
সিনট্যাক্স:
maximum_n(array: ARRAY, n: INT64) -> ARRAY
বর্ণনা:
অ্যারেতে থাকা n সংখ্যক বৃহত্তম মানকে অবরোহী ক্রমে একটি array ফেরত দেয়।
-
NULLমান উপেক্ষা করা হয়। -
nঋণাত্মক হলে, একটি ত্রুটি দেখানো হয়।
উদাহরণ:
| অ্যারে | এন | maximum_n(array, n) |
|---|---|---|
| [১, ৫, ২, ৪, ৩] | ৩ | [৫, ৪, ৩] |
| [১, শূন্য, ৫] | ৩ | [৫, ১] |
সর্বনিম্ন
সিনট্যাক্স:
minimum(array: ARRAY) -> ANY
বর্ণনা:
array সর্বনিম্ন মানটি ফেরত দেয়।
- তুলনা করার সময়
NULLমান উপেক্ষা করা হয়। -
arrayখালি থাকলে বা এতে শুধুমাত্রNULLমান থাকলে,NULLরিটার্ন করা হয়।
উদাহরণ:
| অ্যারে | minimum(array) |
|---|---|
| [১, ৫, ২] | ১ |
| [৫, শূন্য, ১] | ১ |
| ["a", "c", "b"] | "ক" |
| [শূন্য, শূন্য] | নাল |
| [] | নাল |
MINIMUM_N
সিনট্যাক্স:
minimum_n(array: ARRAY, n: INT64) -> ARRAY
বর্ণনা:
array মধ্যে থাকা n সংখ্যক ক্ষুদ্রতম মানকে আরোহী ক্রমে একটি অ্যারেতে ফেরত দেয়।
-
NULLমান উপেক্ষা করা হয়। -
nঋণাত্মক হলে, একটি ত্রুটি দেখানো হয়।
উদাহরণ:
| অ্যারে | এন | minimum_n(array, n) |
|---|---|---|
| [১, ৫, ২, ৪, ৩] | ৩ | [১, ২, ৩] |
| [৫, শূন্য, ১] | ৩ | [১, ৫] |
যোগফল
সিনট্যাক্স:
sum(array: ARRAY) -> INT64 | FLOAT64
বর্ণনা:
একটি ARRAY থাকা সমস্ত NUMERIC মানের যোগফল ফেরত দেয়।
- অ্যারের মধ্যে থাকা অ-সংখ্যাসূচক মানগুলি উপেক্ষা করা হয়।
- অ্যারের কোনো সাংখ্যিক মান
NaNহলে, ফাংশনটিNaNরিটার্ন করে। - অ্যারের মধ্যে থাকা সাংখ্যিক প্রকারের মধ্যে প্রশস্ততমটির উপর ভিত্তি করে রিটার্ন টাইপ নির্ধারিত হয়:
INT64<FLOAT64। - কোনো ফ্লোটিং পয়েন্ট মান যোগ করার আগে যদি ৬৪-বিট পূর্ণসংখ্যার ওভারফ্লো ঘটে, তাহলে একটি ত্রুটি ফেরত দেওয়া হয়। যদি ফ্লোটিং পয়েন্ট মানগুলো যোগ করা হয়, তাহলে ওভারফ্লোর ফলে যোগফল +/- অসীম হবে।
- অ্যারেটিতে যদি কোনো সাংখ্যিক মান না থাকে, তাহলে ফাংশনটি
NULLরিটার্ন করে।
উদাহরণ:
| অ্যারে | sum(array) |
|---|---|
| [১, ২, ৩] | ৬ লিটার |
| [১ লিটার, ২ লিটার, ৩ লিটার] | ৬ লিটার |
| [2000000000, 2000000000] | ৪০০০০০০০০ লিটার |
| [১০, ২০.৫] | ৩০.৫ |
| [1, "a", 2] | ৩ লিটার |
| [INT64.MAX_VALUE, 1] | ত্রুটি |
| [INT64.MAX_VALUE, 1, -1.0] | ত্রুটি |
| [INT64.MAX_VALUE, 1.0] | 9.223372036854776e+18 |
যোগদান করুন
সিনট্যাক্স:
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প্রদান করা না হয়, তাহলেarrayNULLমানগুলো ফলাফল থেকে বাদ দেওয়া হয়।
উদাহরণ:
যখন null_text প্রদান করা হয় না:
| অ্যারে | বিভাজক | join(array, delimiter) |
|---|---|---|
| ["a", "b", "c"] | "," | "ক, খ, গ" |
| ["a", null, "c"] | "," | "এ, সি" |
| [b'a', b'b', b'c'] | খ',' | b'a,b,c' |
| ["a", b'c'] | "," | ত্রুটি |
| ["ক", "গ"] | খ',' | ত্রুটি |
| [b'a', b'c'] | "," | ত্রুটি |
যখন null_text প্রদান করা হয়:
| অ্যারে | বিভাজক | null_text | join(array, delimiter, null_text) |
|---|---|---|---|
| ["a", null, "c"] | "," | "নিখোঁজ" | "a, অনুপস্থিত, c" |
| [b'a', null, b'c'] | খ',' | b'NULL' | b'a,NULL,c' |
| [null, "b", null] | "," | "নিখোঁজ" | "অনুপস্থিত, খ, অনুপস্থিত" |
| [b'a', null, null] | খ',' | b'NULL' | b'a,NULL,NULL' |
| ["a", null] | "," | b'N' | ত্রুটি |
| [b'a', null] | খ',' | "N" | ত্রুটি |
তুলনা ফাংশন
| নাম | বর্ণনা |
EQUAL | সমতা তুলনা |
GREATER_THAN | তুলনার চেয়েও বেশি |
GREATER_THAN_OR_EQUAL | বৃহত্তর বা সমান তুলনা |
LESS_THAN | তুলনার চেয়ে কম |
LESS_THAN_OR_EQUAL | কম বা সমান তুলনা |
NOT_EQUAL | সমান নয় এমন তুলনা |
CMP | সাধারণ তুলনা |
সমান
সিনট্যাক্স:
equal(x: ANY, y: ANY) -> BOOLEAN
উদাহরণ:
x | y | equal(x, y) |
|---|---|---|
| ১ লিটার | ১ লিটার | TRUE |
| ১.০ | ১ লিটার | TRUE |
| -১.০ | ১ লিটার | FALSE |
| NaN | NaN | TRUE |
NULL | NULL | TRUE |
NULL | ABSENT | FALSE |
বর্ণনা:
x এবং y সমান হলে TRUE , অন্যথায় FALSE রিটার্ন করে।
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").equal(5).as_("hasPerfectRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(equal(field("rating"), 5).as("hasPerfectRating")) .execute() .get();
বৃহত্তর_এর চেয়ে
সিনট্যাক্স:
greater_than(x: ANY, y: ANY) -> BOOLEAN
বর্ণনা:
যদি x , y এর চেয়ে বড় হয় তবে TRUE , অন্যথায় FALSE রিটার্ন করে।
যদি x এবং y তুলনীয় না হয়, তাহলে FALSE রিটার্ন করা হয়।
উদাহরণ:
x | y | greater_than(x, y) |
|---|---|---|
| ১ লিটার | ০.০ | TRUE |
| ১ লিটার | ১ লিটার | FALSE |
| ১ লিটার | ২ লিটার | FALSE |
| "ফু" | ০ লিটার | FALSE |
| ০ লিটার | "ফু" | FALSE |
| NaN | ০ লিটার | FALSE |
| ০ লিটার | NaN | FALSE |
NULL | NULL | FALSE |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").greater_than(4).as_("hasHighRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(greaterThan(field("rating"), 4).as("hasHighRating")) .execute() .get();
বৃহত্তর_এর_চেয়ে_বা_সমান
সিনট্যাক্স:
greater_than_or_equal(x: ANY, y: ANY) -> BOOLEAN
বর্ণনা:
যদি x y এর চেয়ে বড় বা সমান হয় তবে TRUE , অন্যথায় FALSE রিটার্ন করে।
যদি x এবং y তুলনীয় না হয়, তাহলে FALSE রিটার্ন করা হয়।
উদাহরণ:
x | y | greater_than_or_equal(x, y) |
|---|---|---|
| ১ লিটার | ০.০ | TRUE |
| ১ লিটার | ১ লিটার | TRUE |
| ১ লিটার | ২ লিটার | FALSE |
| "ফু" | ০ লিটার | FALSE |
| ০ লিটার | "ফু" | FALSE |
| NaN | ০ লিটার | FALSE |
| ০ লিটার | NaN | FALSE |
NULL | NULL | TRUE |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(greaterThanOrEqual(field("published"), 1900).as("publishedIn20thCentury")) .execute() .get();
কম
সিনট্যাক্স:
less_than(x: ANY, y: ANY) -> BOOLEAN
বর্ণনা:
x , y এর চেয়ে ছোট হলে TRUE এবং অন্যথায় FALSE রিটার্ন করে।
যদি x এবং y তুলনীয় না হয়, তাহলে FALSE রিটার্ন করা হয়।
উদাহরণ:
x | y | less_than(x, y) |
|---|---|---|
| ১ লিটার | ০.০ | FALSE |
| ১ লিটার | ১ লিটার | FALSE |
| ১ লিটার | ২ লিটার | TRUE |
| "ফু" | ০ লিটার | FALSE |
| ০ লিটার | "ফু" | FALSE |
| NaN | ০ লিটার | FALSE |
| ০ লিটার | NaN | FALSE |
NULL | NULL | FALSE |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("published").less_than(1923).as_("isPublicDomainProbably")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(lessThan(field("published"), 1923).as("isPublicDomainProbably")) .execute() .get();
কম বা সমান
সিনট্যাক্স:
less_than_or_equal(x: ANY, y: ANY) -> BOOLEAN
বর্ণনা:
x , y এর চেয়ে ছোট বা সমান হলে TRUE এবং অন্যথায় FALSE রিটার্ন করে।
যদি x এবং y তুলনীয় না হয়, তাহলে FALSE রিটার্ন করা হয়।
উদাহরণ:
x | y | less_than(x, y) |
|---|---|---|
| ১ লিটার | ০.০ | FALSE |
| ১ লিটার | ১ লিটার | TRUE |
| ১ লিটার | ২ লিটার | TRUE |
| "ফু" | ০ লিটার | FALSE |
| ০ লিটার | "ফু" | FALSE |
| NaN | ০ লিটার | FALSE |
| ০ লিটার | NaN | FALSE |
NULL | NULL | TRUE |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(lessThanOrEqual(field("rating"), 2).as("hasBadRating")) .execute() .get();
অসমান
সিনট্যাক্স:
not_equal(x: ANY, y: ANY) -> BOOLEAN
বর্ণনা:
যদি x , y এর সমান না হয় তবে TRUE এবং অন্যথায় FALSE রিটার্ন করে।
উদাহরণ:
x | y | not_equal(x, y) |
|---|---|---|
| ১ লিটার | ১ লিটার | FALSE |
| ১.০ | ১ লিটার | FALSE |
| -১.০ | ১ লিটার | TRUE |
| NaN | ০ লিটার | TRUE |
| NaN | NaN | FALSE |
NULL | NULL | FALSE |
NULL | ABSENT | TRUE |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").not_equal("1984").as_("not1984")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(notEqual(field("title"), "1984").as("not1984")) .execute() .get();
সিএমপি
সিনট্যাক্স:
cmp(x: ANY, y: ANY) -> Int64
বর্ণনা:
x ও y তুলনা করে ফেরত দেয়:
-
1Lযদিxyঅপেক্ষা বৃহত্তর হয়। -
-1Lযদিxyথেকে ছোট হয়। - অন্যথায়
0L।
অন্যান্য তুলনা ফাংশনের মতো নয়, cmp(...) ফাংশনটি sort(...) ধাপে ব্যবহৃত একই ক্রম অনুসরণ করে বিভিন্ন টাইপের মধ্যে কাজ করে। বিভিন্ন টাইপের মধ্যে মানগুলি কীভাবে সাজানো হয় তা জানতে 'value type order' দেখুন।
উদাহরণ:
x | y | cmp(x, y) |
|---|---|---|
| ১ লিটার | ১ লিটার | ০ লিটার |
| ১.০ | ১ লিটার | ০ লিটার |
| -১.০ | ১ লিটার | -১ লিটার |
| ৪২.৫ডি | "ফু" | -১ লিটার |
NULL | NULL | ০ লিটার |
NULL | ABSENT | ০ লিটার |
ডিবাগিং ফাংশন
| নাম | বর্ণনা |
EXISTS | মানটি অনুপস্থিত মান না হলে TRUE রিটার্ন করে। |
IS_ABSENT | মানটি অনুপস্থিত হলে TRUE রিটার্ন করে। |
IF_ABSENT | মানটি অনুপস্থিত থাকলে সেটিকে একটি এক্সপ্রেশন দিয়ে প্রতিস্থাপন করে। |
IS_ERROR | অন্তর্নিহিত এক্সপ্রেশন দ্বারা কোনো ত্রুটি নিক্ষিপ্ত হয়েছে কিনা তা শনাক্ত করে এবং পরীক্ষা করে। |
IF_ERROR | যদি কোনো ত্রুটি ঘটে থাকে, তবে মানটিকে একটি এক্সপ্রেশন দিয়ে প্রতিস্থাপন করে। |
ERROR | মূল্যায়ন সমাপ্ত করে এবং নির্দিষ্ট বার্তা সহ একটি ত্রুটি ফেরত দেয়। |
বিদ্যমান
সিনট্যাক্স:
exists(value: ANY) -> BOOLEAN
বর্ণনা:
যদি value অনুপস্থিত মান না হয়, তাহলে TRUE রিটার্ন করে।
উদাহরণ:
value | exists(value) |
|---|---|
| ০ লিটার | TRUE |
| "ফু" | TRUE |
NULL | TRUE |
ABSENT | FALSE |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").exists().as_("hasRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(exists(field("rating")).as("hasRating")) .execute() .get();
অনুপস্থিত
সিনট্যাক্স:
is_absent(value: ANY) -> BOOLEAN
বর্ণনা:
যদি value অনুপস্থিত মান হয় তবে TRUE , এবং অন্যথায় FALSE রিটার্ন করে। অনুপস্থিত মান হলো সেইসব মান যা ইনপুটে নেই, যেমন কোনো ডকুমেন্ট ফিল্ড অনুপস্থিত থাকা।
উদাহরণ:
value | is_absent(value) |
|---|---|
| ০ লিটার | FALSE |
| "ফু" | FALSE |
NULL | FALSE |
ABSENT | TRUE |
IF_ABSENT
সিনট্যাক্স:
if_absent(value: ANY, replacement: ANY) -> ANY
বর্ণনা:
যদি value অনুপস্থিত থাকে, তবে তা মূল্যায়ন করে replacement ফেরত দেয়। অন্যথায় value ফেরত দেয়।
উদাহরণ:
value | replacement | if_absent(value, replacement) |
|---|---|---|
| ৫ লিটার | ০ লিটার | ৫ লিটার |
NULL | ০ লিটার | NULL |
ABSENT | ০ লিটার | ০ লিটার |
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 | ১ লিটার | ১ লিটার |
FALSE | ১ লিটার | ERROR ("no condition matched") |
রেফারেন্স ফাংশন
REFERENCE টাইপটি ডাটাবেসের অন্যান্য ডকুমেন্ট (এমনকি অন্য ডাটাবেসেরও) একটি 'পয়েন্টার' হিসেবে কাজ করে। নিম্নলিখিত ফাংশনগুলো কোয়েরি সম্পাদনের সময় এই টাইপটিকে নিয়ন্ত্রণ করার সুযোগ দেয়।
| নাম | বর্ণনা |
COLLECTION_ID | প্রদত্ত রেফারেন্সে থাকা লিফ কালেকশনের আইডি ফেরত দেয়। |
DOCUMENT_ID | প্রদত্ত রেফারেন্সে থাকা ডকুমেন্টটির আইডি ফেরত দেয়। |
PARENT | প্যারেন্ট রেফারেন্স ফেরত দেয় |
REFERENCE_SLICE | প্রদত্ত রেফারেন্স থেকে সেগমেন্টের একটি উপসেট ফেরত দেয়। |
সংগ্রহের আইডি
সিনট্যাক্স:
collection_id(ref: REFERENCE) -> STRING
বর্ণনা:
প্রদত্ত REFERENCE এর লিফ কালেকশন আইডি ফেরত দেয়।
উদাহরণ:
ref | collection_id(ref) |
|---|---|
users/user1 | "users" |
users/user1/posts/post1 | "posts" |
ডকুমেন্ট_আইডি
সিনট্যাক্স:
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(ref: REFERENCE, offset: INT, length: INT) -> REFERENCE
বর্ণনা:
একটি REFERENCE হলো (collection_id, document_id) টাপলের একটি তালিকা এবং এটি array_slice(...) মতোই সেই তালিকাটি দেখার সুযোগ করে দেয়।
একটি নতুন REFERENCE ফেরত দেয় যা প্রদত্ত ref এর সেগমেন্টগুলোর একটি উপসেট।
-
offset: স্লাইসটির শুরুর সূচক (০-ভিত্তিক)। যদি এটি ঋণাত্মক হয়, তবে এটি রেফারেন্সের শেষ থেকে একটি অফসেট। -
length: স্লাইসটিতে অন্তর্ভুক্ত করার জন্য সেগমেন্টের সংখ্যা।
উদাহরণ:
ref | offset | length | reference_slice(ref, offset, length) |
|---|---|---|---|
a/1/b/2/c/3 | ১ লিটার | ২ লিটার | b/2/c/3 |
a/1/b/2/c/3 | ০ লিটার | ২ লিটার | a/1/b/2 |
a/1/b/2/c/3 | -২ লিটার | ২ লিটার | 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 |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( and(greaterThan(field("rating"), 4), lessThan(field("price"), 10)) .as("under10Recommendation")) .execute() .get();
অথবা
সিনট্যাক্স:
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 |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( or(equal(field("genre"), "Fantasy"), arrayContains(field("tags"), "adventure")) .as("matchesSearchFilters")) .execute() .get();
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 |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( xor( arrayContains(field("tags"), "magic"), arrayContains(field("tags"), "nonfiction")) .as("matchesSearchFilters")) .execute() .get();
নর
সিনট্যাক্স:
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 রিটার্ন করে।
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(not(arrayContains(field("tags"), "nonfiction")).as("isFiction")) .execute() .get();
শর্তসাপেক্ষ
সিনট্যাক্স:
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 | ১ লিটার | ০ লিটার | ১ লিটার |
FALSE | ১ লিটার | ০ লিটার | ০ লিটার |
NULL | ১ লিটার | ০ লিটার | ০ লিটার |
ABSENT | ১ লিটার | ০ লিটার | ০ লিটার |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( arrayConcat( field("tags"), conditional( greaterThan(field("pages"), 100), constant("longRead"), constant("shortRead"))) .as("extendedTags")) .execute() .get();
IF_NULL
সিনট্যাক্স:
if_null(expr: ANY, replacement: ANY) -> ANY
বর্ণনা:
যদি expr NULL না হয়, তবে এটি রিটার্ন করে, অন্যথায় এটি replacement মূল্যায়ন করে রিটার্ন করে। expr ব্যবহৃত হলে replacement এক্সপ্রেশনটি মূল্যায়ন করা হয় না।
উদাহরণ:
expr | replacement | if_null(expr, replacement) |
|---|---|---|
| ১ লিটার | ২ লিটার | ১ লিটার |
NULL | ২ লিটার | ২ লিটার |
ABSENT | ২ লিটার | ABSENT |
সুইচ_অন
সিনট্যাক্স:
switch_on(cond1: BOOLEAN, res1: ANY, cond2: BOOLEAN, res2: ANY, ..., [default: ANY]) -> ANY
বর্ণনা:
একাধিক শর্ত মূল্যায়ন করে এবং প্রথম TRUE শর্তটির সাথে সম্পর্কিত ফলাফলটি ফেরত দেয়। যদি কোনো শর্তই TRUE হিসেবে বিবেচিত না হয়, তবে প্রদত্ত থাকলে default মানটি ফেরত দেওয়া হয়। যদি কোনো default মান প্রদান করা না হয় এবং অন্য কোনো শর্তও TRUE হিসেবে বিবেচিত না হয়, তবে একটি ত্রুটি (error) দেখানো হয়।
default মান প্রদান করতে, সেটিকে শেষ আর্গুমেন্ট হিসেবে এমনভাবে দিন যাতে আর্গুমেন্টের সংখ্যা বিজোড় হয়।
উদাহরণ:
x | switch_on(eq(x, 1L), "one", eq(x, 2L), "two", "other") |
|---|---|
| ১ লিটার | "এক" |
| ২ লিটার | 'দুই' |
| ৩ লিটার | "অন্যান্য" |
যেকোনো সমান
সিনট্যাক্স:
equal_any(value: ANY, search_space: ARRAY) -> BOOLEAN
বর্ণনা:
যদি value search_space অ্যারেতে থাকে তবে TRUE রিটার্ন করে।
উদাহরণ:
value | search_space | equal_any(value, search_space) |
|---|---|---|
| ০ লিটার | [১ লিটার, ২ লিটার, ৩ লিটার] | FALSE |
| ২ লিটার | [১ লিটার, ২ লিটার, ৩ লিটার] | TRUE |
NULL | [১ লিটার, ২ লিটার, ৩ লিটার] | FALSE |
NULL | [1L, NULL ] | TRUE |
ABSENT | [1L, NULL ] | FALSE |
| NaN | [1L, NaN, 3L] | TRUE |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( equalAny(field("genre"), Arrays.asList("Science Fiction", "Psychological Thriller")) .as("matchesGenreFilters")) .execute() .get();
অসমান_কোনোটি
সিনট্যাক্স:
not_equal_any(value: ANY, search_space: ARRAY) -> BOOLEAN
বর্ণনা:
যদি value search_space অ্যারেতে না থাকে তবে TRUE রিটার্ন করে।
উদাহরণ:
value | search_space | not_equal_any(value, search_space) |
|---|---|---|
| ০ লিটার | [১ লিটার, ২ লিটার, ৩ লিটার] | TRUE |
| ২ লিটার | [১ লিটার, ২ লিটার, ৩ লিটার] | FALSE |
NULL | [১ লিটার, ২ লিটার, ৩ লিটার] | TRUE |
NULL | [1L, NULL ] | FALSE |
ABSENT | [1L, NULL ] | TRUE |
| NaN | [1L, NaN, 3L] | FALSE |
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select( notEqualAny(field("author"), Arrays.asList("George Orwell", "F. Scott Fitzgerald")) .as("byExcludedAuthors")) .execute() .get();
সর্বোচ্চ
সিনট্যাক্স:
maximum(x: ANY...) -> ANY
maximum(x: ARRAY) -> ANY
বর্ণনা:
একাধিক x মানের মধ্যে থেকে সর্বোচ্চ অ- NULL ও অ- ABSENT মানটি ফেরত দেয়।
যদি NULL বা ABSENT নয় এমন কোনো মান না থাকে, তাহলে NULL রিটার্ন করা হয়।
যদি একাধিক সর্বোচ্চ সমতুল্য মান থাকে, তবে সেই মানগুলোর যেকোনো একটি ফেরত দেওয়া যেতে পারে। মানের প্রকারের ক্রম নথিভুক্ত ক্রম অনুসরণ করে।
উদাহরণ:
x | y | maximum(x, y) |
|---|---|---|
FALSE | TRUE | TRUE |
FALSE | -১০ লিটার | -১০ লিটার |
| ০.০ | -৫ লিটার | ০.০ |
| "ফু" | "বার" | "ফু" |
| "ফু" | ["ফু"] | ["ফু"] |
ABSENT | ABSENT | NULL |
NULL | NULL | NULL |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").logical_maximum(1).as_("flooredRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(logicalMaximum(field("rating"), 1).as("flooredRating")) .execute() .get();
সর্বনিম্ন
সিনট্যাক্স:
minimum(x: ANY...) -> ANY
minimum(x: ARRAY) -> ANY
বর্ণনা:
একাধিক x মানের মধ্যে সর্বনিম্ন মানটি ফেরত দেয়, যেটি NULL বা ABSENT নয়।
যদি NULL বা ABSENT নয় এমন কোনো মান না থাকে, তাহলে NULL রিটার্ন করা হয়।
যদি একাধিক সর্বনিম্ন সমতুল্য মান থাকে, তবে সেই মানগুলোর যেকোনো একটি ফেরত দেওয়া যেতে পারে। মানের প্রকারের ক্রম নথিভুক্ত ক্রম অনুসরণ করে।
উদাহরণ:
x | y | minimum(x, y) |
|---|---|---|
FALSE | TRUE | FALSE |
FALSE | -১০ লিটার | FALSE |
| ০.০ | -৫ লিটার | -৫ লিটার |
| "ফু" | "বার" | "বার" |
| "ফু" | ["ফু"] | "ফু" |
ABSENT | ABSENT | NULL |
NULL | NULL | NULL |
নোড.জেএস
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("rating").logical_minimum(5).as_("cappedRating")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(logicalMinimum(field("rating"), 5).as("cappedRating")) .execute() .get();
মানচিত্র ফাংশন
| নাম | বর্ণনা |
MAP | একাধিক কী-ভ্যালু জোড় থেকে একটি ম্যাপ ভ্যালু তৈরি করে। |
MAP_GET | একটি নির্দিষ্ট কী দেওয়া হলে ম্যাপের মান ফেরত দেয়। |
MAP_SET | আপডেট করা কী-গুলোর একটি সিরিজ সহ একটি ম্যাপের অনুলিপি ফেরত দেয়। |
MAP_REMOVE | একটি ম্যাপের এমন একটি অনুলিপি ফেরত দেয় যেখান থেকে একাধিক কী (key) সরিয়ে ফেলা হয়েছে। |
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) দেওয়া হলে, ম্যাপের ভেতরের মানটি ফেরত দেয়। যদি key ম্যাপে না থাকে, অথবা map আর্গুমেন্টটি একটি MAP না হয়, তবে একটি ABSENT মান ফেরত দেয়।
নোড.জেএস
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") ) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("awards").map_get("pulitzer").as_("hasPulitzerAward")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) .execute() .get();
মানচিত্র_সেট
সিনট্যাক্স:
map_set(map: MAP, key: STRING, value: ANY, ...) -> MAP
বর্ণনা:
একাধিক কী-ভ্যালু পেয়ার দ্বারা আপডেট করা বিষয়বস্তুসহ map ভ্যালুটির একটি কপি ফেরত দেয়।
যদি প্রদত্ত মানটি অনুপস্থিত থাকে, তাহলে সংশ্লিষ্ট কী-টি ম্যাপ থেকে সরিয়ে দেওয়া হয়।
যদি map আর্গুমেন্টটি একটি MAP না হয়, তাহলে একটি অনুপস্থিত মান ফেরত দেওয়া হয়।
মানচিত্র অপসারণ
সিনট্যাক্স:
map_remove(map: MAP, key: STRING...) -> MAP
বর্ণনা:
map ভ্যালুটির একটি অনুলিপি ফেরত দেয়, যেখান থেকে একাধিক কী (key) সরিয়ে দেওয়া হয়।
মানচিত্র_একত্রীকরণ
সিনট্যাক্স:
map_merge(maps: MAP...) -> MAP
দুই বা ততোধিক ম্যাপের বিষয়বস্তু একত্রিত করে। যদি একাধিক ম্যাপে পরস্পরবিরোধী মান থাকে, তবে সর্বশেষ মানটি ব্যবহৃত হয়।
বর্তমান প্রেক্ষাপট
সিনট্যাক্স:
current_context() -> MAP
বর্তমান কার্য সম্পাদনের মুহূর্তে উপলব্ধ সমস্ত ফিল্ড সম্বলিত একটি ম্যাপ ফেরত দেয়।
মানচিত্রের চাবিগুলি
সিনট্যাক্স:
map_keys(map: MAP) -> ARRAY<STRING>
বর্ণনা:
map ভ্যালুটির সমস্ত কী-গুলো সম্বলিত একটি অ্যারে ফেরত দেয়।
মানচিত্রের মান
সিনট্যাক্স:
map_values(map: MAP) -> ARRAY<ANY>
বর্ণনা:
map ভ্যালুটির সমস্ত মান ধারণকারী একটি অ্যারে ফেরত দেয়।
মানচিত্র এন্ট্রি
সিনট্যাক্স:
map_entries(map: MAP) -> ARRAY<MAP>
বর্ণনা:
map ভ্যালুতে থাকা সমস্ত কী-ভ্যালু পেয়ার সম্বলিত একটি অ্যারে রিটার্ন করে।
প্রতিটি কী-ভ্যালু পেয়ার k এবং v দুটি এন্ট্রি সহ একটি ম্যাপ আকারে থাকবে।
উদাহরণ:
map | map_entries(map) |
|---|---|
| {} | [] |
| {"foo" : 2L} | [{"k": "foo", "v" : 2L}] |
| {"foo" : "বার", "বার" : "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_MATCH | কোনো মানের কোনো অংশ রেগুলার এক্সপ্রেশনের সাথে মিলে গেলে TRUE রিটার্ন করে। |
STRING_CONCAT | একাধিক STRING সংযুক্ত করে একটি STRING তৈরি করে |
STRING_CONTAINS | যদি কোনো মানে একটি STRING থাকে তবে TRUE রিটার্ন করে। |
STRING_INDEX_OF | একটি STRING বা BYTES মানের প্রথম উপস্থিতির ০-ভিত্তিক সূচক ফেরত দেয়। |
TO_UPPER | STRING বা BYTES মানকে বড় হাতের অক্ষরে রূপান্তর করে। |
TO_LOWER | STRING বা BYTES মানকে ছোট হাতের অক্ষরে রূপান্তর করে। |
SUBSTRING | একটি STRING বা BYTES মানের একটি সাবস্ট্রিং গ্রহণ করে। |
STRING_REVERSE | একটি STRING বা BYTES মানকে বিপরীত করে। |
STRING_REPEAT | একটি STRING বা BYTES মানকে নির্দিষ্ট সংখ্যক বার পুনরাবৃত্তি করে। |
STRING_REPLACE_ALL | STRING বা BYTES মানের সমস্ত উপস্থিতি প্রতিস্থাপন করে। |
STRING_REPLACE_ONE | STRING বা BYTES মানের প্রথম উপস্থিতি প্রতিস্থাপন করে। |
TRIM | একটি STRING বা BYTES ভ্যালু থেকে শুরুতে ও শেষে থাকা অক্ষরগুলো ছেঁটে ফেলে। |
LTRIM | STRING বা BYTES ভ্যালু থেকে শুরুর দিকের অক্ষরগুলো ছেঁটে ফেলে। |
RTRIM | STRING বা BYTES মানের শেষের অক্ষরগুলো ছেঁটে ফেলে। |
SPLIT | একটি STRING বা BYTES মানকে একটি অ্যারেতে বিভক্ত করে। |
বাইট_দৈর্ঘ্য
সিনট্যাক্স:
byte_length[T <: STRING | BYTES](value: T) -> INT64
বর্ণনা:
একটি STRING বা BYTES মানের মধ্যে থাকা BYTES সংখ্যা ফেরত দেয়।
উদাহরণ:
| মূল্য | byte_length(value) |
|---|---|
| "এবিসি" | ৩ |
| "xyzabc" | ৬ |
| b"abc" | ৩ |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").byteLength().as("titleByteLength") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").byteLength().alias("titleByteLength") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").byteLength().alias("titleByteLength") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").byte_length().as_("titleByteLength")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(byteLength(field("title")).as("titleByteLength")) .execute() .get();
অক্ষরের দৈর্ঘ্য
সিনট্যাক্স:
char_length(value: STRING) -> INT64
বর্ণনা:
STRING ভ্যালুতে থাকা ইউনিকোড কোড পয়েন্টের সংখ্যা ফেরত দেয়।
উদাহরণ:
| মূল্য | char_length(value) |
|---|---|
| "এবিসি" | ৩ |
| "হ্যালো" | ৫ |
| "বিশ্ব" | ৫ |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").charLength().as("titleCharLength") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").charLength().alias("titleCharLength") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").charLength().alias("titleCharLength") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").char_length().as_("titleCharLength")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(charLength(field("title")).as("titleCharLength")) .execute() .get();
STARTS_WITH
সিনট্যাক্স:
starts_with(value: STRING, prefix: STRING) -> BOOLEAN
বর্ণনা:
যদি value prefix দিয়ে শুরু হয়, তাহলে TRUE রিটার্ন করে।
উদাহরণ:
| মূল্য | উপসর্গ | starts_with(value, prefix) |
|---|---|---|
| "এবিসি" | "ক" | সত্য |
| "এবিসি" | "খ" | মিথ্যা |
| "এবিসি" | "" | সত্য |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").startsWith("The") .as("needsSpecialAlphabeticalSort") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").startsWith("The") .alias("needsSpecialAlphabeticalSort") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").startsWith("The") .alias("needsSpecialAlphabeticalSort") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("title").starts_with("The").as_("needsSpecialAlphabeticalSort") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(startsWith(field("title"), "The").as("needsSpecialAlphabeticalSort")) .execute() .get();
ENDS_WITH
সিনট্যাক্স:
ends_with(value: STRING, postfix: STRING) -> BOOLEAN
বর্ণনা:
যদি value শেষে postfix থাকে, তাহলে TRUE রিটার্ন করে।
উদাহরণ:
| মূল্য | পোস্টফিক্স | ends_with(value, postfix) |
|---|---|---|
| "এবিসি" | "গ" | সত্য |
| "এবিসি" | "খ" | মিথ্যা |
| "এবিসি" | "" | সত্য |
নোড.জেএস
const result = await db.pipeline() .collection("inventory/devices/laptops") .select( field("name").endsWith("16 inch") .as("16InLaptops") ) .execute();
সুইফট
let result = try await db.pipeline() .collection("inventory/devices/laptops") .select([ Field("name").endsWith("16 inch") .as("16InLaptops") ]) .execute()
Kotlin
val result = db.pipeline() .collection("inventory/devices/laptops") .select( field("name").endsWith("16 inch") .alias("16InLaptops") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("inventory/devices/laptops") .select( field("name").endsWith("16 inch") .alias("16InLaptops") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("inventory/devices/laptops") .select(Field.of("name").ends_with("16 inch").as_("16InLaptops")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("inventory/devices/laptops") .select(endsWith(field("name"), "16 inch").as("16InLaptops")) .execute() .get();
লাইক
সিনট্যাক্স:
like(value: STRING, pattern: STRING) -> BOOLEAN
বর্ণনা:
value pattern সাথে মিলে গেলে TRUE রিটার্ন করে।
উদাহরণ:
| মূল্য | প্যাটার্ন | like(value, pattern) |
|---|---|---|
| "ফায়ারস্টোর" | "ফায়ার%" | সত্য |
| "ফায়ারস্টোর" | "%স্টোর" | সত্য |
| "ডেটাস্টোর" | "ডেটা_স্টোর" | সত্য |
| ১০০% | ১০০% | সত্য |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("genre").like("%Fiction") .as("anyFiction") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre").like("%Fiction") .alias("anyFiction") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre").like("%Fiction") .alias("anyFiction") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").like("%Fiction").as_("anyFiction")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(like(field("genre"), "%Fiction").as("anyFiction")) .execute() .get();
REGEX_CONTAINS
সিনট্যাক্স:
regex_contains(value: STRING, pattern: STRING) -> BOOLEAN
বর্ণনা:
যদি value কোনো অংশ pattern সাথে মিলে যায়, তাহলে TRUE রিটার্ন করে। যদি pattern একটি বৈধ রেগুলার এক্সপ্রেশন না হয়, তাহলে এই ফাংশনটি একটি error রিটার্ন করে।
রেগুলার এক্সপ্রেশনগুলো re2 লাইব্রেরির সিনট্যাক্স অনুসরণ করে।
উদাহরণ:
| মূল্য | প্যাটার্ন | regex_contains(value, pattern) |
|---|---|---|
| "ফায়ারস্টোর" | "আগুন" | সত্য |
| "ফায়ারস্টোর" | "স্টোর$" | সত্য |
| "ফায়ারস্টোর" | "ডেটা" | মিথ্যা |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("documents") .select([ Field("title").regexContains("Firestore (Enterprise|Standard)") .as("isFirestoreRelated") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("title").regexContains("Firestore (Enterprise|Standard)") .alias("isFirestoreRelated") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("title").regexContains("Firestore (Enterprise|Standard)") .alias("isFirestoreRelated") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("title") .regex_contains("Firestore (Enterprise|Standard)") .as_("isFirestoreRelated") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select( regexContains(field("title"), "Firestore (Enterprise|Standard)") .as("isFirestoreRelated")) .execute() .get();
REGEX_MATCH
সিনট্যাক্স:
regex_match(value: STRING, pattern: STRING) -> BOOLEAN
বর্ণনা:
যদি value pattern সাথে সম্পূর্ণরূপে মিলে যায় তবে TRUE রিটার্ন করে। যদি pattern একটি বৈধ রেগুলার এক্সপ্রেশন না হয়, তবে এই ফাংশনটি একটি error রিটার্ন করে।
রেগুলার এক্সপ্রেশনগুলো re2 লাইব্রেরির সিনট্যাক্স অনুসরণ করে।
উদাহরণ:
| মূল্য | প্যাটার্ন | regex_match(value, pattern) |
|---|---|---|
| "ফায়ারস্টোর" | "এফ.*স্টোর" | সত্য |
| "ফায়ারস্টোর" | "আগুন" | মিথ্যা |
| "ফায়ারস্টোর" | "^F.*e$" | সত্য |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("documents") .select([ Field("title").regexMatch("Firestore (Enterprise|Standard)") .as("isFirestoreExactly") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("title").regexMatch("Firestore (Enterprise|Standard)") .alias("isFirestoreExactly") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("title").regexMatch("Firestore (Enterprise|Standard)") .alias("isFirestoreExactly") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("title") .regex_match("Firestore (Enterprise|Standard)") .as_("isFirestoreExactly") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select( regexMatch(field("title"), "Firestore (Enterprise|Standard)") .as("isFirestoreExactly")) .execute() .get();
স্ট্রিং_কনক্যাট
সিনট্যাক্স:
string_concat(values: STRING...) -> STRING
বর্ণনা:
দুই বা ততোধিক STRING মানকে সংযুক্ত করে একটি একক ফলাফল তৈরি করে।
উদাহরণ:
| যুক্তি | string_concat(values...) |
|---|---|
() | ত্রুটি |
("a") | "ক" |
("abc", "def") | "abcdef" |
("a", "", "c") | "এসি" |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").concat([" by ", Field("author")]) .as("fullyQualifiedTitle") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").concat(" by ", field("author")) .alias("fullyQualifiedTitle") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").concat(" by ", field("author")) .alias("fullyQualifiedTitle") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("title") .concat(" by ", Field.of("author")) .as_("fullyQualifiedTitle") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(stringConcat(field("title"), " by ", field("author")).as("fullyQualifiedTitle")) .execute() .get();
স্ট্রিং_ধারণ করে
সিনট্যাক্স:
string_contains(value: STRING, substring: STRING) -> BOOLEAN
বর্ণনা:
value আক্ষরিক স্ট্রিং substring আছে কিনা তা যাচাই করে।
উদাহরণ:
| মূল্য | সাবস্ট্রিং | string_contains(value, substring) |
|---|---|---|
| "এবিসি" | "খ" | সত্য |
| "এবিসি" | "d" | মিথ্যা |
| "এবিসি" | "" | সত্য |
| "এসি" | "." | সত্য |
| "☃☃☃" | "☃" | সত্য |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("articles") .select([ Field("body").stringContains("Firestore") .as("isFirestoreRelated") ]) .execute()
Kotlin
val result = db.pipeline() .collection("articles") .select( field("body").stringContains("Firestore") .alias("isFirestoreRelated") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("articles") .select( field("body").stringContains("Firestore") .alias("isFirestoreRelated") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("articles") .select(Field.of("body").string_contains("Firestore").as_("isFirestoreRelated")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("articles") .select(stringContains(field("body"), "Firestore").as("isFirestoreRelated")) .execute() .get();
স্ট্রিং_সূচক_অফ
সিনট্যাক্স:
string_index_of[T <: STRING | BYTES](value: T, search: T) -> INT64
বর্ণনা:
value তে search এর প্রথম উপস্থিতির ০-ভিত্তিক সূচকটি ফেরত দেয়।
-
searchখুঁজে না পেলে-1ফেরত দেয়। - যদি
valueএকটিSTRINGহয়, তাহলে ফলাফলটি ইউনিকোড কোড পয়েন্টে পরিমাপ করা হয়। আর যদি এটি একটিBYTESহয়, তাহলে তা বাইটে পরিমাপ করা হয়। - যদি
searchভ্যালুটি একটি খালিSTRINGবাBYTESহয়, তাহলে ফলাফল হবে0।
উদাহরণ:
| মূল্য | অনুসন্ধান | string_index_of(value, search) |
|---|---|---|
| "হ্যালো ওয়ার্ল্ড" | "ও" | ৪ |
| "হ্যালো ওয়ার্ল্ড" | "l" | ২ |
| "হ্যালো ওয়ার্ল্ড" | "z" | -১ |
| 'কলা' | "না" | ২ |
| "এবিসি" | "" | ০ |
| b"abc" | খ"খ" | ১ |
| "é" | "é" | ০ |
| b"é" | b"é" | ০ |
TO_UPPER
সিনট্যাক্স:
to_upper[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
STRING বা BYTES মানকে বড় হাতের অক্ষরে রূপান্তর করে।
যদি কোনো বাইট বা ক্যারেক্টার UTF-8 এর ছোট হাতের বর্ণমালার সাথে সঙ্গতিপূর্ণ না হয়, তবে তা অপরিবর্তিতভাবে প্রেরণ করা হয়।
উদাহরণ:
| মূল্য | to_upper(value) |
|---|---|
| "এবিসি" | "এবিসি" |
| "AbC" | "এবিসি" |
| b"abc" | b"ABC" |
| b"a1c" | b"A1C" |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("authors") .select([ Field("name").toUpper() .as("uppercaseName") ]) .execute()
Kotlin
val result = db.pipeline() .collection("authors") .select( field("name").toUpper() .alias("uppercaseName") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("authors") .select( field("name").toUpper() .alias("uppercaseName") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("authors") .select(Field.of("name").to_upper().as_("uppercaseName")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("authors") .select(toUpper(field("name")).as("uppercaseName")) .execute() .get();
TO_LOWER
সিনট্যাক্স:
to_lower[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
STRING বা BYTES মানকে ছোট হাতের অক্ষরে রূপান্তর করে।
যদি কোনো বাইট বা ক্যারেক্টার UTF-8 এর বড় হাতের বর্ণমালার সাথে সঙ্গতিপূর্ণ না হয়, তবে তা অপরিবর্তিতভাবে প্রেরণ করা হয়।
উদাহরণ:
| মূল্য | to_lower(value) |
|---|---|
| "এবিসি" | "এবিসি" |
| "AbC" | "এবিসি" |
| "এ১সি" | "a1c" |
| b"ABC" | b"abc" |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("authors") .select([ Field("genre").toLower().equal("fantasy") .as("isFantasy") ]) .execute()
Kotlin
val result = db.pipeline() .collection("authors") .select( field("genre").toLower().equal("fantasy") .alias("isFantasy") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("authors") .select( field("genre").toLower().equal("fantasy") .alias("isFantasy") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("authors") .select(Field.of("genre").to_lower().equal("fantasy").as_("isFantasy")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("authors") .select(equal(toLower(field("genre")), "fantasy").as("isFantasy")) .execute() .get();
সাবস্ট্রিং
সিনট্যাক্স:
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ভ্যালু হয়, তবে তা বাইটে পরিমাপ করা হয়।যদি
positioninputদৈর্ঘ্যের চেয়ে বড় হয়, তাহলে একটি খালি সাবস্ট্রিং ফেরত দেওয়া হয়। যদিpositionওlengthযোগফলinputদৈর্ঘ্যের চেয়ে বড় হয়, তাহলে সাবস্ট্রিংটিinputশেষ পর্যন্ত ছেঁটে ফেলা হয়।positionঋণাত্মক হলে, ইনপুটের শেষ থেকে অবস্থানটি নেওয়া হয়। যদি ঋণাত্মকpositionইনপুটের আকারের চেয়ে বড় হয়, তবে অবস্থানটি শূন্যে সেট করা হয়।lengthঅবশ্যই অঋণাত্মক হতে হবে।
উদাহরণ:
যখন length প্রদান করা হয় না:
| ইনপুট | অবস্থান | substring(input, position) |
|---|---|---|
| "এবিসি" | ০ | "এবিসি" |
| "এবিসি" | ১ | "বিসি" |
| "এবিসি" | ৩ | "" |
| "এবিসি" | -১ | "গ" |
| b"abc" | ১ | b"bc" |
যখন length প্রদান করা হয়:
| ইনপুট | অবস্থান | দৈর্ঘ্য | substring(input, position, length) |
|---|---|---|---|
| "এবিসি" | ০ | ১ | "ক" |
| "এবিসি" | ১ | ২ | "বিসি" |
| "এবিসি" | -১ | ১ | "গ" |
| b"abc" | ০ | ১ | খ"ক" |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .where(Field("title").startsWith("The ")) .select([ Field("title").substring(position: 4) .as("titleWithoutLeadingThe") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .where(field("title").startsWith("The ")) .select( field("title") .substring(constant(4), field("title").charLength().subtract(4)) .alias("titleWithoutLeadingThe") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .where(field("title").startsWith("The ")) .select( field("title").substring( constant(4), field("title").charLength().subtract(4)) .alias("titleWithoutLeadingThe") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .where(Field.of("title").starts_with("The ")) .select(Field.of("title").substring(4).as_("titleWithoutLeadingThe")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .where(startsWith(field("title"), "The ")) .select( substring(field("title"), constant(4), field("title").charLength()) .as("titleWithoutLeadingThe")) .execute() .get();
স্ট্রিং_রিভার্স
সিনট্যাক্স:
string_reverse[T <: STRING | BYTES](input: T) -> T
বর্ণনা:
প্রদত্ত ইনপুট বিপরীত ক্রমে ফেরত দেয়।
ইনপুটটি STRING হলে ক্যারেক্টারগুলোকে ইউনিকোড কোড পয়েন্ট দ্বারা এবং বাইট BYTES ভ্যালু হলে বাইট দ্বারা চিহ্নিত করা হয়।
উদাহরণ:
| ইনপুট | string_reverse(input) |
|---|---|
| "এবিসি" | "cba" |
| "a🌹b" | "b🌹a" |
| "হ্যালো" | "ওলেহ" |
| b"abc" | b"cba" |
নোড.জেএস
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") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("name").reverse().as("reversedName") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("name").reverse().alias("reversedName") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("name").reverse().alias("reversedName") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("name").string_reverse().as_("reversedName")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(reverse(field("name")).as("reversedName")) .execute() .get();
স্ট্রিং_রিপিট
সিনট্যাক্স:
string_repeat[T <: STRING | BYTES](input: T, repetitions: INT64) -> T
বর্ণনা:
input repetitions সংখ্যা ফেরত দেয়।
-
repetitionsঅবশ্যই একটি অঋণাত্মক পূর্ণসংখ্যা হতে হবে। -
repetitionsসংখ্যা0হলে,inputমতোই একটি খালি মান ফেরত দেওয়া হয়। - ফলাফল সর্বোচ্চ অনুমোদিত আকার (১ এমবি) অতিক্রম করলে একটি ত্রুটি দেখানো হয়।
উদাহরণ:
| ইনপুট | পুনরাবৃত্তি | string_repeat(input, repetitions) |
|---|---|---|
| "ফু" | ৩ | "ফুফুফু" |
| "ফু" | ০ | "" |
| "ক" | ৩ | "আআআ" |
| b"ab" | ২ | b"abab" |
| "é🦆" | ২ | "é🦆é🦆" |
সব স্ট্রিং প্রতিস্থাপন করুন
সিনট্যাক্স:
string_replace_all[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T
বর্ণনা:
input find এর সকল অ-ওভারল্যাপিং উপস্থিতিকে ' replacement দ্বারা প্রতিস্থাপন করে।
- মিলগুলো কেস-সেনসিটিভ।
-
findখালি থাকলে, কোনো প্রতিস্থাপন করা হয় না।
উদাহরণ:
| ইনপুট | খুঁজুন | প্রতিস্থাপন | string_replace_all(input, find, replacement) |
|---|---|---|---|
| "ফুবারফু" | "ফু" | "বাজ" | "বাজবারবাজ" |
| "আবাবাব" | "আবা" | "গ" | "cbab" |
| "ফুবার" | "ও" | "" | "fbar" |
| "é🦆🌎🦆" | "🦆" | "ক" | "éa🌎a" |
| b"abc" | খ"খ" | খ"দ" | b"adc" |
স্ট্রিং_রিপ্লেস_ওয়ান
সিনট্যাক্স:
string_replace_one[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T
বর্ণনা:
input find এর প্রথম উপস্থিতিকে replacement দিয়ে প্রতিস্থাপন করে।
- মিলগুলো কেস-সেনসিটিভ।
-
findখালি থাকলে, কোনো প্রতিস্থাপন করা হয় না।
উদাহরণ:
| ইনপুট | খুঁজুন | প্রতিস্থাপন | string_replace_one(input, find, replacement) |
|---|---|---|---|
| "ফুবারফু" | "ফু" | "বাজ" | "বাজবারফু" |
| "é" | "é" | "ক" | "ক" |
| b"foobar" | b"o" | b"z" | b"fzoobar" |
ট্রিম
সিনট্যাক্স:
trim[T <: STRING | BYTES](input: T, values_to_trim: T) -> T
trim[T <: STRING | BYTES](input: T) -> T
বর্ণনা:
প্রদত্ত input শুরু এবং শেষ থেকে একটি নির্দিষ্ট সংখ্যক BYTES বা CHARS ছেঁটে ফেলে।
- যদি
values_to_trimপ্রদান করা না হয়, তাহলে হোয়াইটস্পেস অক্ষরগুলো ছেঁটে ফেলা হয়।
উদাহরণ:
যখন values_to_trim প্রদান করা হয় না:
| ইনপুট | trim(input) |
|---|---|
| "ফু" | "ফু" |
| b" foo " | b"foo" |
| "ফু" | "ফু" |
| "" | "" |
| " | "" |
| "\t ফু \n" | "ফু" |
| b"\t foo \n" | b"foo" |
| "\r\f\v foo \r\f\v" | "ফু" |
| b"\r\f\v foo \r\f\v" | b"foo" |
যখন values_to_trim প্রদান করা হয়:
| ইনপুট | values_to_trim | trim(input, values_to_trim) |
|---|---|---|
| "abcbfooaacb" | "এবিসি" | "ফু" |
| "abcdaabadbac" | "এবিসি" | "দাবাদ" |
| b"C1C2C3" | খ"সি১" | b"C2C3" |
| b"C1C2" | "ফু" | ত্রুটি |
| "ফু" | খ"সি১" | ত্রুটি |
Web
const result = await execute(db.pipeline() .collection("books") .select( field("name").trim().as("whitespaceTrimmedName") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("name").trim(" \n\t").as("whitespaceTrimmedName") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("name").trim().alias("whitespaceTrimmedName") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("name").trim().alias("whitespaceTrimmedName") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("name").trim().as_("whitespaceTrimmedName")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(trim(field("name")).as("whitespaceTrimmedName")) .execute() .get();
এলটিআরআইএম
সিনট্যাক্স:
ltrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
ltrim[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
প্রদত্ত value শুরু থেকে একটি নির্দিষ্ট সংখ্যক BYTES বা CHARS ছেঁটে ফেলে।
-
to_trimপ্রদান করা না হলে, শুরুর দিকের অতিরিক্ত স্পেস অক্ষরগুলো ছেঁটে ফেলা হয়।
উদাহরণ:
যখন to_trim প্রদান করা হয় না:
| মূল্য | ltrim(value) |
|---|---|
| "ফু" | "ফু" |
| "ফু" | "ফু" |
যখন to_trim প্রদান করা হয়:
| মূল্য | ছাঁটাই করতে | ltrim(value, to_trim) |
|---|---|---|
| "aaabc" | "ক" | "বিসি" |
| "আবাকাবা" | "বা" | "কাবা" |
| "é" | "é" | "" |
আরটিআরআইএম
সিনট্যাক্স:
rtrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
rtrim[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
প্রদত্ত value শেষ থেকে একটি নির্দিষ্ট সংখ্যক BYTES বা CHARS ছেঁটে ফেলে।
- যদি
to_trimপ্রদান করা না হয়, তাহলে শেষের অতিরিক্ত স্পেস অক্ষরগুলো ছেঁটে ফেলা হয়।
উদাহরণ:
যখন to_trim প্রদান করা হয় না:
| মূল্য | rtrim(value) |
|---|---|
| "ফু" | "ফু" |
| "ফু" | "ফু" |
যখন to_trim প্রদান করা হয়:
| মূল্য | ছাঁটাই করতে | rtrim(value, to_trim) |
|---|---|---|
| "abccc" | "গ" | "ab" |
| "আবাকাবা" | "বা" | "অ্যাবাক" |
| "é" | "é" | "" |
বিভক্ত
সিনট্যাক্স:
split(input: STRING) -> ARRAY<STRING>
split[T <: STRING | BYTES](input: T, delimiter: T) -> ARRAY<T>
বর্ণনা:
একটি ডিলিমিটার ব্যবহার করে কোনো STRING বা BYTES ভ্যালুকে বিভক্ত করে।
STRINGএর ক্ষেত্রে ডিফল্ট ডিলিমিটার হলো কমা (,)। ডিলিমিটারটিকে একটি একক স্ট্রিং হিসেবে গণ্য করা হয়।BYTESএর ক্ষেত্রে, আপনাকে অবশ্যই একটি বিভাজক নির্দিষ্ট করতে হবে।খালি ডিলিমিটার দিয়ে স্প্লিট করলে
STRINGভ্যালুগুলোর জন্য ইউনিকোড কোডপয়েন্টের একটি অ্যারে এবংBYTESভ্যালুগুলোর জন্যBYTESএর একটি অ্যারে তৈরি হয়।একটি খালি
STRINGস্প্লিট করলে একটিARRAYফেরত আসে, যার মধ্যে একটিমাত্র খালিSTRINGথাকে।
উদাহরণ:
যখন delimiter প্রদান করা হয় না:
| ইনপুট | split(input) |
|---|---|
| "ফু, বার, ফু" | ["foo", "bar", "foo"] |
| "ফু" | ["ফু"] |
| ",ফু," | ["", "ফু", ""] |
| "" | [""] |
| b"C120C2C4" | ত্রুটি |
যখন delimiter প্রদান করা হয়:
| ইনপুট | বিভাজক | split(input, delimiter) |
|---|---|---|
| "ফু বার ফু" | " | ["foo", "bar", "foo"] |
| "ফু বার ফু" | "z" | ["ফু বার ফু"] |
| "এবিসি" | "" | ["a", "b", "c"] |
| খ"সি১,সি২,সি৪" | খ"," | [b"C1", b"C2", b"C4"] |
| b"ABC" | খ" | [b"A", b"B", b"C"] |
| "ফু" | খ"সি১" | ত্রুটি |
টাইমস্ট্যাম্প ফাংশন
| নাম | বর্ণনা |
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 | Converts the number of seconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP |
TIMESTAMP_ADD | Adds a time interval to a TIMESTAMP |
TIMESTAMP_SUB | Subtracts a time interval to a TIMESTAMP |
TIMESTAMP_TO_UNIX_MICROS | Converts a TIMESTAMP to the number of microseconds since 1970-01-01 00:00:00 UTC |
TIMESTAMP_TO_UNIX_MILLIS | Converts a TIMESTAMP to the number of milliseconds since 1970-01-01 00:00:00 UTC |
TIMESTAMP_TO_UNIX_SECONDS | Converts a TIMESTAMP to the number of seconds since 1970-01-01 00:00:00 UTC |
TIMESTAMP_DIFF | Returns the whole number of specified unit intervals between two TIMESTAMP s. |
TIMESTAMP_EXTRACT | Extracts a specific part (eg year, month, day) from a TIMESTAMP . |
CURRENT_TIMESTAMP
Syntax:
current_timestamp() -> TIMESTAMP
বর্ণনা:
Gets the timestamp at the beginning of request time input (interpreted as the number of microseconds since 1970-01-01 00:00:00 UTC ).
This is stable within a query, and will always resolve to the same value if called multiple times.
TIMESTAMP_TRUNC
Syntax:
timestamp_trunc(timestamp: TIMESTAMP, granularity: STRING[, timezone: STRING]) -> TIMESTAMP
বর্ণনা:
Truncates a timestamp down to a given granularity.
The granularity argument must be a string and one of the following:
-
microsecond -
millisecond -
second -
minute -
hour -
day -
week -
week([weekday]) -
month -
quarter -
year -
isoyear
If the timezone argument is provided, truncation will be based on the given timezone's calendar boundaries (eg day truncation will truncate to midnight in the given timezone). The truncation will respect daylight savings time.
If timezone is not provided, truncation will be based on UTC calendar boundaries.
The timezone argument should be a string representation of a timezone from the tz database, for example America/New_York . A custom time offset can also be used by specifying an offset from GMT .
Examples:
timestamp | granularity | timezone | timestamp_trunc(timestamp, granularity, timezone) |
|---|---|---|---|
| 2000-01-01 10:20:30:123456 UTC | "second" | Not provided | 2001-01-01 10:20:30 UTC |
| 1997-05-31 04:30:30 UTC | "day" | Not provided | 1997-05-31 00:00:00 UTC |
| 1997-05-31 04:30:30 UTC | "day" | "America/Los_Angeles" | 1997-05-30 07:00:00 UTC |
| 2001-03-16 04:00:00 UTC | "week(friday) | Not provided | 2001-03-16 00:00:00 UTC |
| 2001-03-23 04:00:00 UTC | "week(friday) | "America/Los_Angeles" | 2001-03-23 17:00:00 UTC |
| 2026-01-24 20:00:00 UTC | "month" | "GMT+06:32:43" | 2026-01-01T06:32:43 UTC |
UNIX_MICROS_TO_TIMESTAMP
Syntax:
unix_micros_to_timestamp(input: INT64) -> TIMESTAMP
বর্ণনা:
Converts input (interpreted as the number of microseconds since 1970-01-01 00:00:00 UTC ) to a TIMESTAMP . Throws an error if input cannot be converted to a valid TIMESTAMP .
Examples:
input | unix_micros_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 UTC |
| 400123456L | 1970-01-01 00:06:40.123456 UTC |
| -1000000L | 1969-12-31 23:59:59 UTC |
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(unixMicrosToTimestamp(field("createdAtMicros")).as("createdAtString")) .execute() .get();
UNIX_MILLIS_TO_TIMESTAMP
Syntax:
unix_millis_to_timestamp(input: INT64) -> TIMESTAMP
বর্ণনা:
Converts input (interpreted as the number of milliseconds since 1970-01-01 00:00:00 UTC ) to a TIMESTAMP . Throws an error if input cannot be converted to a valid TIMESTAMP .
Examples:
input | unix_millis_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 UTC |
| 4000123L | 1970-01-01 01:06:40.123 UTC |
| -1000000L | 1969-12-31 23:43:20 UTC |
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(unixMillisToTimestamp(field("createdAtMillis")).as("createdAtString")) .execute() .get();
UNIX_SECONDS_TO_TIMESTAMP
Syntax:
unix_seconds_to_timestamp(input: INT64) -> TIMESTAMP
বর্ণনা:
Converts input (interpreted as the number of seconds since 1970-01-01 00:00:00 UTC ) to a TIMESTAMP . Throws an error if input cannot be converted to a valid TIMESTAMP .
Examples:
input | unix_seconds_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 UTC |
| 60L | 1970-01-01 00:01:00 UTC |
| -300L | 1969-12-31 23:55:00 UTC |
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(unixSecondsToTimestamp(field("createdAtSeconds")).as("createdAtString")) .execute() .get();
TIMESTAMP_ADD
Syntax:
timestamp_add(timestamp: TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP
বর্ণনা:
Adds an amount of unit from timestamp . The amount argument can be negative, in that case it is equivalent to TIMESTAMP_SUB .
The unit argument must be a string and one of the following:
-
microsecond -
millisecond -
second -
minute -
hour -
day
Throws an error if the resulting timestamp does not fit within the TIMESTAMP range.
Examples:
timestamp | unit | amount | timestamp_add(timestamp, unit, amount) |
|---|---|---|---|
| 2025-02-20 00:00:00 UTC | "minute" | 2L | 2025-02-20 00:02:00 UTC |
| 2025-02-20 00:00:00 UTC | "hour" | -4L | 2025-02-19 20:00:00 UTC |
| 2025-02-20 00:00:00 UTC | "day" | 5L | 2025-02-25 00:00:00 UTC |
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampAdd(field("createdAt"), "day", 3653).as("expiresAt")) .execute() .get();
TIMESTAMP_SUB
Syntax:
timestamp_sub(timestamp: TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP
বর্ণনা:
Subtracts an amount of unit from timestamp . The amount argument can be negative, in that case it is equivalent to TIMESTAMP_ADD .
The unit argument must be a string and one of the following:
-
microsecond -
millisecond -
second -
minute -
hour -
day
Throws an error if the resulting timestamp does not fit within the TIMESTAMP range.
Examples:
timestamp | unit | amount | timestamp_sub(timestamp, unit, amount) |
|---|---|---|---|
| 2026-07-04 00:00:00 UTC | "minute" | 40L | 2026-07-03 23:20:00 UTC |
| 2026-07-04 00:00:00 UTC | "hour" | -24L | 2026-07-05 00:00:00 UTC |
| 2026-07-04 00:00:00 UTC | "day" | 3L | 2026-07-01 00:00:00 UTC |
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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampSubtract(field("expiresAt"), "day", 14).as("sendWarningTimestamp")) .execute() .get();
TIMESTAMP_TO_UNIX_MICROS
Syntax:
timestamp_to_unix_micros(input: TIMESTAMP) -> INT64
বর্ণনা:
Converts input to the number of microseconds since 1970-01-01 00:00:00 UTC . Truncates higher levels of precision by rounding down to the beginning of the microsecond.
Examples:
input | timestamp_to_unix_micros(input) |
|---|---|
| 1970-01-01 00:00:00 UTC | 0L |
| 1970-01-01 00:06:40.123456 UTC | 400123456L |
| 1969-12-31 23:59:59 UTC | -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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampToUnixMicros(field("dateString")).as("unixMicros")) .execute() .get();
TIMESTAMP_TO_UNIX_MILLIS
Syntax:
timestamp_to_unix_millis(input: TIMESTAMP) -> INT64
বর্ণনা:
Converts input to the number of milliseconds since 1970-01-01 00:00:00 UTC . Truncates higher levels of precision by rounding down to the beginning of the millisecond.
Examples:
input | timestamp_to_unix_millis(input) |
|---|---|
| 1970-01-01 00:00:00 UTC | 0L |
| 1970-01-01 01:06:40.123 UTC | 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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampToUnixMillis(field("dateString")).as("unixMillis")) .execute() .get();
TIMESTAMP_TO_UNIX_SECONDS
Syntax:
timestamp_to_unix_seconds(input: TIMESTAMP) -> INT64
বর্ণনা:
Converts input to the number of seconds since 1970-01-01 00:00:00 UTC . Truncates higher levels of precision by rounding down to the beginning of the second.
Examples:
input | timestamp_to_unix_seconds(input) |
|---|---|
| 1970-01-01 00:00:00 UTC | 0L |
| 1970-01-01 00:01:00 UTC | 60L |
| 1969-12-31 23:55:00 UTC | -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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select(timestampToUnixSeconds(field("dateString")).as("unixSeconds")) .execute() .get();
TIMESTAMP_DIFF
Syntax:
timestamp_diff(end: TIMESTAMP, start: TIMESTAMP, unit: STRING) -> INT64
বর্ণনা:
Returns the whole number of specified unit intervals between two TIMESTAMP s.
- Returns a negative value if
endis beforestart. - Truncates any fractional unit. For example,
timestamp_diff("2021-01-01 00:00:01", "2021-01-01 00:00:00", "minute")returns0.
The unit argument must be a string and one of the following:
-
microsecond -
millisecond -
second -
minute -
hour -
day
Examples:
end | start | unit | timestamp_diff(end, start, unit) |
|---|---|---|---|
| 2026-07-04 00:01:00 UTC | 2026-07-04 00:00:00 UTC | "second" | 60L |
| 2026-07-04 00:00:00 UTC | 2026-07-05 00:00:00 UTC | "day" | -1L |
| 2026-07-04 00:00:59 UTC | 2026-07-04 00:00:00 UTC | "minute" | 0L |
TIMESTAMP_EXTRACT
Syntax:
timestamp_extract(timestamp: TIMESTAMP, part: STRING[, timezone: STRING]) -> INT64
বর্ণনা:
Extracts a specific part (eg year, month, day) from timestamp .
The part argument must be a string and one of the following:
-
microsecond -
millisecond -
second -
minute -
hour -
day -
dayofweek: Returns a value between 1 (Sunday) and 7 (Saturday). -
dayofyear -
week: Returns the week number of the year, starting at 1 for the first Sunday of the year. -
week([weekday]): Returns the week number of the year, starting on the specifiedweekday. -
month -
quarter -
year -
isoweek: Returns the ISO 8601 week number. -
isoyear: Returns the ISO 8601 week-numbering year.
If the timezone argument is provided, the extraction will be based on the given timezone's calendar. The extraction will respect daylight savings time.
If timezone is not provided, extraction will be based on UTC .
The timezone argument should be a string representation of a timezone from the timezone database, for example America/New_York . A custom time offset can also be used by specifying an offset from GMT .
Examples:
timestamp | part | timezone | timestamp_extract(timestamp, part, timezone) |
|---|---|---|---|
| 2025-02-20 10:20:30 UTC | "year" | Not provided | ২০২৫ |
| 2025-02-20 10:20:30 UTC | "day" | Not provided | ২০ |
| 2025-12-31 23:59:59 UTC | "year" | "Asia/Tokyo" | ২০২৬ |
Type Functions
| নাম | বর্ণনা |
TYPE | Returns the type of the value as a STRING . |
IS_TYPE | Returns true if the value matches the specified type. |
TYPE
Syntax:
type(input: ANY) -> STRING
বর্ণনা:
Returns a string representation of the input type.
If given an absent value, returns NULL .
Examples:
input | type(input) |
|---|---|
| NULL | "null" |
| সত্য | "boolean" |
| ১ | "int32" |
| -3L | "int64" |
| 3.14 | "float64" |
| 2024-01-01T00:00:00Z UTC | "timestamp" |
| "foo" | "string" |
| b"foo" | "bytes" |
| [1, 2] | "array" |
| {"a": 1} | "map" |
path("c/d") | "reference" |
vector([1.0, 2.0]) | "vector" |
| ABSENT | NULL |
Client examples
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")) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").not_equal("1984").as_("not1984")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(notEqual(field("title"), "1984").as("not1984")) .execute() .get();
IS_TYPE
Syntax:
is_type(input: ANY, type: STRING) -> BOOLEAN
বর্ণনা:
Returns true if the input matches the specified type , otherwise false . If given an absent input , returns NULL .
Supported type strings are:
-
"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"
Examples:
input | type | is_type(input, type) |
|---|---|---|
| NULL | "null" | সত্য |
| সত্য | "boolean" | সত্য |
| 3.14 | "float64" | সত্য |
| "foo" | "string" | সত্য |
| b"foo" | "string" | মিথ্যা |
| [1, 2] | "array" | সত্য |
| {"a": 1} | "map" | সত্য |
vector([1.0, 2.0]) | "vector" | সত্য |
| ABSENT | "string" | NULL |
| "bar" | "other" | ERROR |
Vector Functions
| নাম | বর্ণনা |
COSINE_DISTANCE | Returns the cosine distance between two vectors |
DOT_PRODUCT | Returns the dot product between two vectors |
EUCLIDEAN_DISTANCE | Returns the euclidean distance between two vectors |
MANHATTAN_DISTANCE | Returns the manhattan distance between two vectors |
VECTOR_LENGTH | Returns the number of elements in a vector |
COSINE_DISTANCE
Syntax:
cosine_distance(x: VECTOR, y: VECTOR) -> FLOAT64
বর্ণনা:
Returns the cosine distance between x and 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")));
সুইফট
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();
পাইথন
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() )
জাভা
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();
DOT_PRODUCT
Syntax:
dot_product(x: VECTOR, y: VECTOR) -> FLOAT64
বর্ণনা:
Returns the dot product of x and 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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
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();
EUCLIDEAN_DISTANCE
Syntax:
euclidean_distance(x: VECTOR, y: VECTOR) -> FLOAT64
বর্ণনা:
Computes the euclidean distance between x and 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") ) );
সুইফট
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();
পাইথন
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() )
জাভা
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();
MANHATTAN_DISTANCE
Syntax:
manhattan_distance(x: VECTOR, y: VECTOR) -> FLOAT64
বর্ণনা:
Computes the manhattan distance between x and y .
VECTOR_LENGTH
Syntax:
vector_length(vector: VECTOR) -> INT64
বর্ণনা:
Returns the number of elements in a 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") ) );
সুইফট
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();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("embedding").vector_length().as_("vectorLength")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(vectorLength(field("embedding")).as("vectorLength")) .execute() .get();