তুলনা করার ফাংশন

তুলনা করার ফাংশন

নাম বিবরণ
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 রিটার্ন করে।

Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").equal(5).as("hasPerfectRating"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("rating").equal(5).as("hasPerfectRating"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("rating").equal(5).as("hasPerfectRating")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("rating").equal(5).alias("hasPerfectRating"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("rating").equal(5).alias("hasPerfectRating"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").equal(5).as_("hasPerfectRating"))
    .execute()
)
জাভা
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(equal(field("rating"), 5).as("hasPerfectRating"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.Equal(firestore.FieldOf("rating"), 5).As("hasPerfectRating"),
	)).
	Execute(ctx)

GREATER_THAN

সিনট্যাক্স:

greater_than(x: ANY, y: ANY) -> BOOLEAN

বিবরণ:

x, y-এর থেকে বড় হলে TRUE রিটার্ন করে, অন্যথায় FALSE রিটার্ন করে।

x এবং y তুলনীয় না হলে, FALSE রিটার্ন করে।

উদাহরণ:

x y greater_than(x, y)
১ লিটার ০.০ TRUE
১ লিটার ১ লিটার FALSE
১ লিটার 2L FALSE
"foo" ০ লিটার FALSE
০ লিটার "foo" FALSE
NaN ০ লিটার FALSE
০ লিটার NaN FALSE
NULL NULL FALSE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").greaterThan(4).as("hasHighRating"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("rating").greaterThan(4).as("hasHighRating"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("rating").greaterThan(4).as("hasHighRating")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("rating").greaterThan(4).alias("hasHighRating"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("rating").greaterThan(4).alias("hasHighRating"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").greater_than(4).as_("hasHighRating"))
    .execute()
)
জাভা
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(greaterThan(field("rating"), 4).as("hasHighRating"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.GreaterThan(firestore.FieldOf("rating"), 4).As("hasHighRating"),
	)).
	Execute(ctx)

GREATER_THAN_OR_EQUAL

সিনট্যাক্স:

greater_than_or_equal(x: ANY, y: ANY) -> BOOLEAN

বিবরণ:

x, y-এর থেকে বড় বা সমান হলে TRUE রিটার্ন করে, অন্যথায় FALSE রিটার্ন করে।

x এবং y তুলনীয় না হলে, FALSE রিটার্ন করে।

উদাহরণ:

x y greater_than_or_equal(x, y)
১ লিটার ০.০ TRUE
১ লিটার ১ লিটার TRUE
১ লিটার 2L FALSE
"foo" ০ লিটার FALSE
০ লিটার "foo" FALSE
NaN ০ লিটার FALSE
০ লিটার NaN FALSE
NULL NULL TRUE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("published").greaterThanOrEqual(1900).as("publishedIn20thCentury")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("published").greaterThanOrEqual(1900).alias("publishedIn20thCentury"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("published").greaterThanOrEqual(1900).alias("publishedIn20thCentury"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(
        Field.of("published")
        .greater_than_or_equal(1900)
        .as_("publishedIn20thCentury")
    )
    .execute()
)
জাভা
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(greaterThanOrEqual(field("published"), 1900).as("publishedIn20thCentury"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.GreaterThanOrEqual(firestore.FieldOf("published"), 1900).As("publishedIn20thCentury"),
	)).
	Execute(ctx)

LESS_THAN

সিনট্যাক্স:

less_than(x: ANY, y: ANY) -> BOOLEAN

বিবরণ:

x, y-এর থেকে ছোট হলে TRUE দেখায়, অন্যথায় FALSE দেখায়।

x এবং y তুলনীয় না হলে, FALSE রিটার্ন করে।

উদাহরণ:

x y less_than(x, y)
১ লিটার ০.০ FALSE
১ লিটার ১ লিটার FALSE
১ লিটার 2L TRUE
"foo" ০ লিটার FALSE
০ লিটার "foo" FALSE
NaN ০ লিটার FALSE
০ লিটার NaN FALSE
NULL NULL FALSE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("published").lessThan(1923).as("isPublicDomainProbably"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("published").lessThan(1923).as("isPublicDomainProbably"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("published").lessThan(1923).as("isPublicDomainProbably")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("published").lessThan(1923).alias("isPublicDomainProbably"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("published").lessThan(1923).alias("isPublicDomainProbably"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("published").less_than(1923).as_("isPublicDomainProbably"))
    .execute()
)
জাভা
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(lessThan(field("published"), 1923).as("isPublicDomainProbably"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.LessThan(firestore.FieldOf("published"), 1923).As("isPublicDomainProbably"),
	)).
	Execute(ctx)

LESS_THAN_OR_EQUAL

সিনট্যাক্স:

less_than_or_equal(x: ANY, y: ANY) -> BOOLEAN

বিবরণ:

x, y-এর থেকে ছোট বা সমান হলে TRUE এবং অন্যথায় FALSE দেখায়।

x এবং y তুলনীয় না হলে, FALSE রিটার্ন করে।

উদাহরণ:

x y less_than(x, y)
১ লিটার ০.০ FALSE
১ লিটার ১ লিটার TRUE
১ লিটার 2L TRUE
"foo" ০ লিটার FALSE
০ লিটার "foo" FALSE
NaN ০ লিটার FALSE
০ লিটার NaN FALSE
NULL NULL TRUE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("rating").lessThanOrEqual(2).as("hasBadRating"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("rating").lessThanOrEqual(2).as("hasBadRating"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("rating").lessThanOrEqual(2).as("hasBadRating")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("rating").lessThanOrEqual(2).alias("hasBadRating"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("rating").lessThanOrEqual(2).alias("hasBadRating"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("rating").less_than_or_equal(2).as_("hasBadRating"))
    .execute()
)
জাভা
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(lessThanOrEqual(field("rating"), 2).as("hasBadRating"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.LessThanOrEqual(firestore.FieldOf("rating"), 2).As("hasBadRating"),
	)).
	Execute(ctx)

NOT_EQUAL

সিনট্যাক্স:

not_equal(x: ANY, y: ANY) -> BOOLEAN

বিবরণ:

x, y-এর সমান না হলে TRUE রিটার্ন করে, অন্যথায় FALSE রিটার্ন করে।

উদাহরণ:

x y not_equal(x, y)
১ লিটার ১ লিটার FALSE
১.০ ১ লিটার FALSE
-১.০ ১ লিটার TRUE
NaN ০ লিটার TRUE
NaN NaN FALSE
NULL NULL FALSE
NULL ABSENT TRUE
Node.js
const result = await db.pipeline()
  .collection("books")
  .select(field("title").notEqual("1984").as("not1984"))
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("books")
  .select(field("title").notEqual("1984").as("not1984"))
);
Swift
let result = try await db.pipeline()
  .collection("books")
  .select([Field("title").notEqual("1984").as("not1984")])
  .execute()

Kotlin

val result = db.pipeline()
    .collection("books")
    .select(field("title").notEqual("1984").alias("not1984"))
    .execute()

Java

Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("books")
    .select(field("title").notEqual("1984").alias("not1984"))
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("books")
    .select(Field.of("title").not_equal("1984").as_("not1984"))
    .execute()
)
জাভা
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("books")
        .select(notEqual(field("title"), "1984").as("not1984"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("books").
	Select(firestore.Fields(
		firestore.NotEqual(firestore.FieldOf("title"), "1984").As("not1984"),
	)).
	Execute(ctx)

CMP

সিনট্যাক্স:

cmp(x: ANY, y: ANY) -> Int64

বিবরণ:

x ও y-এর তুলনা করে, ফলাফল দেখায়:

  • x, y-এর থেকে বড় হলে 1L।
  • x, y-এর থেকে কম হলে -1L।
  • অন্যথায় 0L।

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

উদাহরণ:

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