Açıklama
Önceden tanımlanmış sabit bir doküman grubunu arayarak dokümanları döndürür.
Aşama, giriş olarak bir veya daha fazla belge almalıdır ve yinelenen yollara sahip belgeler içeremez. Referans verilen bir doküman mevcut değilse bu doküman yolu için sonuç üretilmez.
Bu aşama, Cloud Firestore'nin batchGet aşamasına benzer şekilde çalışır ve toplu işlemden sonra filtreleme sonrası adımları uygulamak yerine sonuçları doğrudan filtrelemeye olanak tanır.
Örnekler
Web
const results = await execute(db.pipeline() .documents([ doc(db, "cities", "SF"), doc(db, "cities", "DC"), doc(db, "cities", "NY") ]) );
Swift
let results = try await db.pipeline() .documents([ db.collection("cities").document("SF"), db.collection("cities").document("DC"), db.collection("cities").document("NY") ]).execute()
Kotlin
val results = db.pipeline() .documents( db.collection("cities").document("SF"), db.collection("cities").document("DC"), db.collection("cities").document("NY") ).execute()
Java
Task<Pipeline.Snapshot> results = db.pipeline() .documents( db.collection("cities").document("SF"), db.collection("cities").document("DC"), db.collection("cities").document("NY") ).execute();
Python
results = ( client.pipeline() .documents( client.collection("cities").document("SF"), client.collection("cities").document("DC"), client.collection("cities").document("NY"), ) .execute() )
Java
Pipeline.Snapshot results = firestore .pipeline() .documents( firestore.collection("cities").document("SF"), firestore.collection("cities").document("DC"), firestore.collection("cities").document("NY")) .execute() .get();
Go
snapshot := client.Pipeline(). Documents([]*firestore.DocumentRef{ client.Collection("cities").Doc("SF"), client.Collection("cities").Doc("DC"), client.Collection("cities").Doc("NY"), }). Execute(ctx)
Davranış
documents(...) aşamasını kullanabilmek için bu aşamanın ardışık düzendeki ilk aşama olarak görünmesi gerekir.
documents(...) aşamasından döndürülen belgelerin sırası kararsızdır ve güvenilir değildir. Belirleyici bir sıralama elde etmek için sonraki bir sort(...) aşaması kullanılabilir.
Örneğin, aşağıdaki belgeler için:
Node.js
await db.collection("cities").doc("SF").set({name: "San Francsico", state: "California"});
await db.collection("cities").doc("NYC").set({name: "New York City", state: "New York"});
await db.collection("cities").doc("CHI").set({name: "Chicago", state: "Illinois"});
documents(...) aşaması, yalnızca SF ve NYC dokümanlarını almak ve ardından bunları ada göre artan düzende sıralamak için kullanılabilir.
Node.js
const results = await db.pipeline()
.documents(
db.collection("cities").doc("SF"),
db.collection("cities").doc("NYC"))
.sort(field("name").ascending())
.execute();
Bu sorgu aşağıdaki dokümanları oluşturur:
{ name: "New York City", state: "New York" }
{ name: "San Francsico", state: "California" }