ডেটাবেস

বিবরণ

বিভিন্ন কালেকশন ও নেস্টেড লেভেল জুড়ে ডেটাবেসের মধ্যে থাকা সব ডকুমেন্ট ফেরত পাঠায়।

উদাহরণ

Web

// Count all documents in the database
const results = await execute(db.pipeline()
  .database()
  .aggregate(countAll().as("total"))
  );
Swift
// Count all documents in the database
let results = try await db.pipeline()
  .database()
  .aggregate([CountAll().as("total")])
  .execute()

Kotlin

// Count all documents in the database
val results = db.pipeline()
    .database()
    .aggregate(AggregateFunction.countAll().alias("total"))
    .execute()

Java

      // Count all documents in the database
Task<Pipeline.Snapshot> results = db.pipeline()
    .database()
    .aggregate(AggregateFunction.countAll().alias("total"))
    .execute();
    
Python
from google.cloud.firestore_v1.pipeline_expressions import Count

# Count all documents in the database
results = client.pipeline().database().aggregate(Count().as_("total")).execute()
জাভা
// Count all documents in the database
Pipeline.Snapshot results =
    firestore.pipeline().database().aggregate(countAll().as("total")).execute().get();
Go
// Count all documents in the database
snapshot := client.Pipeline().
	Database().
	Aggregate(firestore.Accumulators(firestore.CountAll().As("total"))).
	Execute(ctx)

আচরণ

database(...) স্টেজ ব্যবহার করতে হলে, এটিকে পাইপলাইনের প্রথম স্টেজ হিসেবে দেখাতে হবে।

database(...) স্টেজ থেকে ফেরত আসা ডকুমেন্টের ক্রম পরিবর্তনশীল এবং এর উপর নির্ভর করা যায় না। নির্ধারক ক্রম পেতে পরবর্তী sort(...) স্টেজ ব্যবহার করা যেতে পারে।

যেমন, নিম্নলিখিত ডকুমেন্টের জন্য:

Node.js

await db.collection("cities").doc("SF").set({name: "San Francsico", state: "California", population: 800000});
await db.collection("states").doc("CA").set({name: "California", population: 39000000});
await db.collection("countries").doc("USA").set({name: "United States of America", population: 340000000});

database(...) স্টেজ ব্যবহার করে ডেটাবেসে থাকা সব ডকুমেন্ট ফিরিয়ে আনা যেতে পারে।

Node.js

const results = await db.pipeline()
  .database()
  .sort(field("population").ascending())
  .execute();

এই কোয়েরি নিম্নলিখিত ডকুমেন্ট তৈরি করে:

  { name: "San Francsico", state: "California", population: 800000 }
  { name: "California", population: 39000000 }
  { name: "United States of America", population: 340000000 }