বর্ণনা
এর প্যারেন্ট নির্বিশেষে, নির্দিষ্ট কালেকশন আইডিযুক্ত যেকোনো কালেকশন থেকে সমস্ত ডকুমেন্ট ফেরত দেয়।
উদাহরণ
Web
const results = await execute(db.pipeline() .collectionGroup("games") .sort(field("name").ascending()) );
সুইফট
let results = try await db.pipeline() .collectionGroup("games") .sort([Field("name").ascending()]) .execute()
Kotlin
val results = db.pipeline() .collectionGroup("games") .sort(field("name").ascending()) .execute()
Java
Task<Pipeline.Snapshot> results = db.pipeline() .collectionGroup("games") .sort(field("name").ascending()) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field results = ( client.pipeline() .collection_group("games") .sort(Field.of("name").ascending()) .execute() )
জাভা
Pipeline.Snapshot results = firestore .pipeline() .collectionGroup("games") .sort(ascending(field("name"))) .execute() .get();
যান
snapshot := client.Pipeline(). CollectionGroup("games"). Sort(firestore.Orders(firestore.Ascending(firestore.FieldOf("name")))). Execute(ctx)
আচরণ
collection_group(...) পর্যায়টি ব্যবহার করতে হলে, এটিকে পাইপলাইনের প্রথম পর্যায় হিসেবে থাকতে হবে।
collection_group(...) পর্যায় থেকে প্রাপ্ত ডকুমেন্টগুলোর ক্রম অস্থিতিশীল এবং এর উপর নির্ভর করা যায় না। Cloud Firestore সবচেয়ে কার্যকর উপায়ে কোয়েরিটি চালানোর চেষ্টা করবে, যা স্কিমা বা ইনডেক্স কনফিগারেশনের উপর নির্ভর করে ক্রম পরিবর্তন করতে পারে। একটি সুনির্দিষ্ট ক্রম পাওয়ার জন্য পরবর্তী sort(...) ` পর্যায় ব্যবহার করা যেতে পারে।
উদাহরণস্বরূপ, নিম্নলিখিত নথিগুলির জন্য:
নোড.জেএস
await db.collection("cities/SF/departments").doc("building").set({name: "SF Building Deparment", employees: 750});
await db.collection("cities/NY/departments").doc("building").set({name: "NY Building Deparment", employees: 1000});
await db.collection("cities/CHI/departments").doc("building").set({name: "CHI Building Deparment", employees: 900});
await db.collection("cities/NY/departments").doc("finance").set({name: "NY Finance Deparment", employees: 1200});
ডেটাবেসের সমস্ত প্যারেন্ট কালেকশনের প্রতিটি ডিপার্টমেন্টস কালেকশন থেকে ডকুমেন্ট ফেরত পেতে ` collection_group(...) পর্যায়টি ব্যবহার করা যেতে পারে।
নোড.জেএস
const results = await db.pipeline()
.collectionGroup("departments")
.sort(field("employees").ascending())
.execute();
এই কোয়েরিটি নিম্নলিখিত ডকুমেন্টগুলো তৈরি করে:
{ name: "SF Building Deparment", employees: 750 }
{ name: "CHI Building Deparment", employees: 900 }
{ name: "NY Building Deparment", employees: 1000 }
{ name: "NY Finance Deparment", employees: 1200 }