如果我們想通過ID來查詢一個檔案,我們可以這樣做:
firebase
.firestore()
.collection("Your collection")
.doc("documentId")
.get()
.then((docRef) => { console. log(docRef.data()) })
.catch((error) => { })
如何在給定的ID串列中查詢一組檔案,例如:
如何在給定的ID串列中查詢一組檔案?
var list_of_ids = ["documentId1"/span>, "documentId2", "documentId3"]
火庫
.firestore()
.collection("Your collection")
.doc(list_of_ids)
.get()
.then((docRef) => { console. log(docRef.data()) })
.catch((error) => { })
答案是
。謝謝Dharmaraj.
var list_of_ids = ["documentId1"/span>, "documentId2", "documentId3"]
火庫
.firestore()
.collection("Your collection")
.where('__name__', 'in', list_of_ids)
.get()
.then((docRef) => { console. log(docRef.data()) })
.catch((error) => { })
uj5u.com熱心網友回復:
如果陣列中的ID小于或等于10,那么你可以使用in運算子:
.where('__name__', 'in', list_of_ids)
如果陣列包含超過10個專案,那么你將不得不為每個檔案提出單獨的請求(或者以10個為一批)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/308576.html
標籤:
