তুলনামূলক ফাংশন

তুলনা ফাংশন

নাম বর্ণনা
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

বর্ণনা:

xy তুলনা করে ফেরত দেয়:

  • 1L যদি x y অপেক্ষা বৃহত্তর হয়।
  • -1L যদি x y থেকে ছোট হয়।
  • অন্যথায় 0L

অন্যান্য তুলনা ফাংশনের মতো নয়, cmp(...) ফাংশনটি sort(...) ধাপে ব্যবহৃত একই ক্রম অনুসরণ করে বিভিন্ন টাইপের মধ্যে কাজ করে। বিভিন্ন টাইপের মধ্যে মানগুলি কীভাবে সাজানো হয় তা জানতে 'value type order' দেখুন।

উদাহরণ:

x y cmp(x, y)
১ লিটার ১ লিটার ০ লিটার
১.০ ১ লিটার ০ লিটার
-১.০ ১ লিটার -১ লিটার
৪২.৫ডি "ফু" -১ লিটার
NULL NULL ০ লিটার
NULL ABSENT ০ লিটার