যৌক্তিক ফাংশন
| নাম | বর্ণনা |
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();