@firebase/firestore

ฟังก์ชั่น

การทำงาน คำอธิบาย
ฟังก์ชั่น(แอพ, ...)
getFirestore (แอป) ส่งคืนอินสแตนซ์ Firestore เริ่มต้นที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp ที่ให้มา . หากไม่มีอินสแตนซ์ ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น
getFirestore (แอป, รหัสฐานข้อมูล) (เบต้า) ส่งคืนอินสแตนซ์ Firestore ที่มีชื่อที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp ที่ให้มา . หากไม่มีอินสแตนซ์ ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น
InitializeFirestore (แอพ, การตั้งค่า, รหัสฐานข้อมูล) เริ่มต้นอินสแตนซ์ใหม่ของ Firestore ด้วยการตั้งค่าที่ให้ไว้ สามารถเรียกได้ก่อนฟังก์ชันอื่นๆ เท่านั้น รวมถึง getFirestore() . หากการตั้งค่าแบบกำหนดเองว่างเปล่า ฟังก์ชันนี้จะเทียบเท่ากับการเรียก getFirestore() .
ฟังก์ชั่น(ร้านดับเพลิง, ...)
clearIndexedDbPersistence (ที่เก็บไฟ) ล้างที่เก็บข้อมูลถาวร ซึ่งรวมถึงการเขียนที่รอดำเนินการและเอกสารแคช ต้องถูกเรียกในขณะที่อินสแตนซ์ Firestore ไม่ได้เริ่มทำงาน (หลังจากแอปถูกยกเลิกหรือเมื่อแอปเริ่มต้นครั้งแรก) เมื่อเริ่มต้น จะต้องเรียกใช้ฟังก์ชันนี้ก่อนฟังก์ชันอื่นๆ (นอกเหนือจาก InitializeFirestore() หรือ getFirestore() )). หากอินสแตนซ์ Firestore ยังคงทำงานอยู่ สัญญาจะถูกปฏิเสธพร้อมรหัสข้อผิดพลาดของ failed-precondition หมายเหตุ: clearIndexedDbPersistence() มีจุดมุ่งหมายเพื่อช่วยเขียนการทดสอบที่เชื่อถือได้ซึ่งใช้ Cloud Firestore เป็นหลัก ใช้กลไกที่มีประสิทธิภาพในการทิ้งข้อมูลที่มีอยู่แต่ไม่ได้พยายามเขียนทับอย่างปลอดภัยหรือทำให้ข้อมูลแคชไม่สามารถกู้คืนได้ สำหรับแอปพลิเคชันที่มีความละเอียดอ่อนต่อการเปิดเผยข้อมูลแคชระหว่างเซสชันของผู้ใช้ เราขอแนะนำอย่างยิ่งว่าอย่าเปิดใช้งานการคงอยู่เลย
คอลเลกชัน (firestore, เส้นทาง, pathSegments) รับอินสแตนซ์ CollectionReference ที่อ้างถึงคอลเลกชันที่เส้นทางสัมบูรณ์ที่ระบุ
collectionGroup (firestore, collectionId) สร้างและส่งคืนอินสแตนซ์ Query ใหม่ที่มีเอกสารทั้งหมดในฐานข้อมูลที่มีอยู่ในคอลเลกชันหรือคอลเลกชันย่อยด้วย collectionId ที่กำหนด
ConnectFirestoreEmulator (firestore, โฮสต์, พอร์ต, ตัวเลือก) แก้ไขอินสแตนซ์นี้เพื่อสื่อสารกับโปรแกรมจำลอง Cloud Firestore หมายเหตุ: จะต้องเรียกสิ่งนี้ก่อนที่จะใช้อินสแตนซ์นี้เพื่อดำเนินการใดๆ
ปิดการใช้งานเครือข่าย (firestore) ปิดใช้งานการใช้งานเครือข่ายสำหรับอินสแตนซ์นี้ สามารถเปิดใช้งานอีกครั้งได้ผ่านทาง EnableNetwork() . ขณะที่เครือข่ายถูกปิดใช้งาน ผู้ฟังสแน็ปช็อต การเรียก getDoc() หรือ getDocs() จะส่งกลับผลลัพธ์จากแคช และการดำเนินการเขียนใดๆ จะถูกจัดคิวจนกว่าเครือข่ายจะได้รับการกู้คืน
doc (firestore, เส้นทาง, pathSegments) รับอินสแตนซ์ DocumentReference ที่อ้างอิงถึงเอกสารที่เส้นทางสัมบูรณ์ที่ระบุ
EnableIndexedDbPersistence (firestore, การคงอยู่การตั้งค่า) พยายามเปิดใช้งานที่เก็บข้อมูลถาวร หากเป็นไปได้ เมื่อเกิดความล้มเหลว enableIndexedDbPersistence() จะปฏิเสธสัญญาหรือส่งข้อยกเว้น มีสาเหตุหลายประการที่ทำให้สิ่งนี้ล้มเหลว ซึ่งสามารถระบุได้ด้วย code บนข้อผิดพลาด * เงื่อนไขเบื้องต้นล้มเหลว: แอปเปิดอยู่แล้วในแท็บเบราว์เซอร์อื่น * ไม่ได้ใช้งาน: เบราว์เซอร์เข้ากันไม่ได้กับการใช้งานการคงอยู่แบบออฟไลน์ โปรดทราบว่าแม้หลังจากเกิดความล้มเหลว อินสแตนซ์ Firestore จะยังคงใช้งานได้ แต่การคงอยู่แบบออฟไลน์จะถูกปิดใช้งาน หมายเหตุ: ต้องเรียก enableIndexedDbPersistence() ก่อนฟังก์ชันอื่นๆ (นอกเหนือจาก InitializeFirestore() , getFirestore() หรือ clearIndexedDbPersistence() . ความคงอยู่ไม่สามารถใช้ในสภาพแวดล้อม Node.js
เปิดใช้งาน MultiTabIndexedDbPersistence (firestore) พยายามเปิดใช้งานที่เก็บข้อมูลถาวรแบบหลายแท็บ หากเป็นไปได้ หากเปิดใช้งานในทุกแท็บ การดำเนินการทั้งหมดจะแชร์การเข้าถึงการคงอยู่ภายในเครื่อง รวมถึงการดำเนินการสืบค้นร่วมกันและการอัปเดตเอกสารในเครื่องที่มีการชดเชยเวลาแฝงในอินสแตนซ์ที่เชื่อมต่อทั้งหมด เมื่อเกิดความล้มเหลว enableMultiTabIndexedDbPersistence() จะปฏิเสธสัญญาหรือส่งข้อยกเว้น มีสาเหตุหลายประการที่ทำให้สิ่งนี้ล้มเหลว ซึ่งสามารถระบุได้ด้วย code บนข้อผิดพลาด * เงื่อนไขเบื้องต้นล้มเหลว: แอปเปิดอยู่แล้วในแท็บเบราว์เซอร์อื่นและไม่ได้เปิดใช้งานหลายแท็บ * ไม่ได้ใช้งาน: เบราว์เซอร์เข้ากันไม่ได้กับการใช้งานการคงอยู่แบบออฟไลน์ โปรดทราบว่าแม้หลังจากเกิดความล้มเหลว อินสแตนซ์ Firestore จะยังคงใช้งานได้ แต่การคงอยู่แบบออฟไลน์จะถูกปิดใช้งาน
เปิดใช้งานเครือข่าย (firestore) เปิดใช้งานการใช้เครือข่ายอีกครั้งสำหรับอินสแตนซ์ Firestore นี้หลังจากการเรียกครั้งก่อนเพื่อ ปิดการใช้งานเครือข่าย () .
getPersistentCacheIndexManager (firestore) ส่งคืน PersistentCache Index Manager ที่ใช้โดยออบเจ็กต์ Firestore ที่กำหนด อินสแตนซ์ PersistentCacheIndexManager หรือ null หากไม่ได้ใช้งานที่เก็บข้อมูลถาวรในเครื่อง
loadBundle (firestore, BundleData) โหลดบันเดิล Firestore ลงในแคชในเครื่อง
ชื่อแบบสอบถาม (firestore ชื่อ) อ่าน Firestore Query จากแคชในเครื่อง ระบุด้วยชื่อที่กำหนด การสืบค้นที่มีชื่อจะถูกรวมเป็นกลุ่มบนฝั่งเซิร์ฟเวอร์ (พร้อมกับเอกสารผลลัพธ์) และโหลดไปยังแคชในเครื่องโดยใช้ loadBundle เมื่ออยู่ในแคชในเครื่องแล้ว ให้ใช้วิธีนี้เพื่อแยก แบบสอบถาม ตามชื่อ
onSnapshotsInSync (firestore ผู้สังเกตการณ์) แนบ Listener สำหรับเหตุการณ์ Snapshots-in-Sync เหตุการณ์สแนปชอตในการซิงค์ระบุว่า Listener ทั้งหมดที่ได้รับผลกระทบจากการเปลี่ยนแปลงที่กำหนดได้เริ่มทำงานแล้ว แม้ว่าการเปลี่ยนแปลงที่สร้างโดยเซิร์ฟเวอร์เดี่ยวจะส่งผลต่อ Listener หลายคนก็ตาม หมายเหตุ: เหตุการณ์สแนปชอตในการซิงค์บ่งชี้ว่าผู้ฟังซิงค์กันเท่านั้น แต่ไม่เกี่ยวข้องกับว่าสแน็ปช็อตเหล่านั้นซิงค์กับเซิร์ฟเวอร์หรือไม่ ใช้ SnapshotMetadata ใน Listener แต่ละรายการเพื่อตรวจสอบว่าสแน็ปช็อตมาจากแคชหรือเซิร์ฟเวอร์
onSnapshotsInSync (firestore, onSync) แนบ Listener สำหรับเหตุการณ์ Snapshots-in-Sync เหตุการณ์สแนปชอตในการซิงค์ระบุว่า Listener ทั้งหมดที่ได้รับผลกระทบจากการเปลี่ยนแปลงที่กำหนดได้เริ่มทำงานแล้ว แม้ว่าการเปลี่ยนแปลงที่สร้างโดยเซิร์ฟเวอร์เดี่ยวจะส่งผลต่อ Listener หลายคนก็ตาม หมายเหตุ: เหตุการณ์สแนปชอตในการซิงค์บ่งชี้ว่าผู้ฟังซิงค์กันเท่านั้น แต่ไม่เกี่ยวข้องกับว่าสแน็ปช็อตเหล่านั้นซิงค์กับเซิร์ฟเวอร์หรือไม่ ใช้ SnapshotMetadata ใน Listener แต่ละรายการเพื่อตรวจสอบว่าสแน็ปช็อตมาจากแคชหรือเซิร์ฟเวอร์
runTransaction (firestore, updateFunction, ตัวเลือก) ดำเนินการ updateFunction ที่กำหนด จากนั้นพยายามที่จะยอมรับการเปลี่ยนแปลงที่ใช้ภายในธุรกรรม หากเอกสารใดๆ ที่อ่านภายในธุรกรรมมีการเปลี่ยนแปลง Cloud Firestore จะพยายาม updateFunction อีกครั้ง หากล้มเหลวในการดำเนินการหลังจากพยายาม 5 ครั้ง ธุรกรรมจะล้มเหลว จำนวนการเขียนสูงสุดที่อนุญาตในธุรกรรมเดียวคือ 500
setIndexConfiguration (firestore, การกำหนดค่า) (เบต้า) กำหนดค่าการจัดทำดัชนีสำหรับการดำเนินการค้นหาในเครื่อง การกำหนดค่าดัชนีก่อนหน้าใดๆ จะถูกแทนที่ Promise จะได้รับการแก้ไขเมื่อการกำหนดค่าดัชนียังคงอยู่ รายการดัชนีจะถูกสร้างขึ้นแบบอะซิงโครนัส คุณสามารถใช้แบบสอบถามที่จำเป็นต้องมีการสร้างดัชนีต่อไปได้ แม้ว่าดัชนีจะยังไม่พร้อมใช้งานก็ตาม การดำเนินการค้นหาจะเริ่มใช้ดัชนีโดยอัตโนมัติเมื่อมีการเขียนรายการดัชนีแล้ว รองรับดัชนีเฉพาะกับความคงอยู่ของ IndexedDb เท่านั้น หากไม่ได้เปิดใช้งาน IndexedDb การกำหนดค่าดัชนีใดๆ จะถูกละเว้น
setIndexConfiguration (firestore, json) (เบต้า) กำหนดค่าการจัดทำดัชนีสำหรับการดำเนินการค้นหาในเครื่อง การกำหนดค่าดัชนีก่อนหน้าใดๆ จะถูกแทนที่ Promise จะได้รับการแก้ไขเมื่อการกำหนดค่าดัชนียังคงอยู่ รายการดัชนีจะถูกสร้างขึ้นแบบอะซิงโครนัส คุณสามารถใช้แบบสอบถามที่จำเป็นต้องมีการสร้างดัชนีต่อไปได้ แม้ว่าดัชนีจะยังไม่พร้อมใช้งานก็ตาม การดำเนินการค้นหาจะเริ่มใช้ดัชนีโดยอัตโนมัติเมื่อมีการเขียนรายการดัชนีแล้ว รองรับดัชนีเฉพาะกับความคงอยู่ของ IndexedDb เท่านั้น เรียกใช้ enableIndexedDbPersistence() หรือ enableMultiTabIndexedDbPersistence() ก่อนที่จะตั้งค่าการกำหนดค่าดัชนี หากไม่ได้เปิดใช้งาน IndexedDb การกำหนดค่าดัชนีใดๆ จะถูกละเว้น วิธีการนี้ยอมรับรูปแบบ JSON ที่ส่งออกโดย Firebase CLI ( firebase firestore:indexes ) หากรูปแบบ JSON ไม่ถูกต้อง วิธีการนี้จะทำให้เกิดข้อผิดพลาด
ยุติ (ร้านดับเพลิง) ยุติอินสแตนซ์ Firestore ที่ระบุ หลังจากการเรียก terminate() สามารถใช้ฟังก์ชัน clearIndexedDbPersistence() เท่านั้น ฟังก์ชั่นอื่น ๆ จะส่ง FirestoreError หากต้องการรีสตาร์ทหลังจากสิ้นสุด ให้สร้างอินสแตนซ์ใหม่ของ FirebaseFirestore ด้วย getFirestore() . การยุติจะไม่ยกเลิกการเขียนที่ค้างอยู่ และสัญญาใด ๆ ที่รอการตอบกลับจากเซิร์ฟเวอร์จะไม่ได้รับการแก้ไข หากคุณเปิดใช้งานการคงอยู่ ครั้งต่อไปที่คุณเริ่มอินสแตนซ์นี้ อินสแตนซ์จะกลับมาส่งการเขียนเหล่านี้ไปยังเซิร์ฟเวอร์อีกครั้ง หมายเหตุ: ภายใต้สถานการณ์ปกติ ไม่จำเป็นต้องเรียก terminate() ฟังก์ชันนี้มีประโยชน์เฉพาะเมื่อคุณต้องการบังคับให้อินสแตนซ์นี้ปล่อยทรัพยากรทั้งหมดหรือใช้ร่วมกับ clearIndexedDbPersistence() เพื่อให้แน่ใจว่าสถานะภายในเครื่องทั้งหมดจะถูกทำลายระหว่างการทดสอบรัน
waitForPendingWrites (firestore) รอจนกว่าการเขียนที่รอดำเนินการในปัจจุบันทั้งหมดสำหรับผู้ใช้ที่ใช้งานอยู่จะได้รับการยอมรับจากแบ็กเอนด์ สัญญาที่ส่งคืนจะได้รับการแก้ไขทันทีหากไม่มีการเขียนที่ค้างอยู่ มิฉะนั้นสัญญาจะรอการเขียนที่ออกก่อนหน้านี้ทั้งหมด (รวมถึงการเขียนในเซสชันแอปก่อนหน้า) แต่จะไม่รอการเขียนที่เพิ่มเข้ามาหลังจากการเรียกใช้ฟังก์ชัน หากคุณต้องการรอการเขียนเพิ่มเติม ให้เรียก waitForPendingWrites() อีกครั้ง waitForPendingWrites() ที่ค้างอยู่จะถูกปฏิเสธระหว่างการเปลี่ยนแปลงผู้ใช้
writeBatch (ร้านดับเพลิง) สร้างแบตช์การเขียน ซึ่งใช้สำหรับการดำเนินการเขียนหลายรายการเป็นการดำเนินการอะตอมมิกเดียว จำนวนการเขียนสูงสุดที่อนุญาตใน WriteBatch เดียวคือ 500 ซึ่งแตกต่างจากธุรกรรมตรงที่ชุดการเขียนจะคงอยู่แบบออฟไลน์ ดังนั้นจึงเป็นที่นิยมมากกว่าเมื่อคุณไม่จำเป็นต้องกำหนดเงื่อนไขการเขียนในข้อมูลที่อ่าน
การทำงาน()
นับ() สร้างวัตถุ AggregateField ที่สามารถใช้เพื่อคำนวณจำนวนเอกสารในชุดผลลัพธ์ของแบบสอบถาม
ลบฟิลด์() ส่งคืน Sentinel เพื่อใช้กับ updateDoc() หรือ setDoc() ด้วย {merge: true} เพื่อทำเครื่องหมายฟิลด์สำหรับการลบ
รหัสเอกสาร() ส่งกลับ FieldPath พิเศษเพื่ออ้างอิงถึง ID ของเอกสาร สามารถใช้ในแบบสอบถามเพื่อเรียงลำดับหรือกรองตามรหัสเอกสาร
getFirestore() ส่งคืนอินสแตนซ์ Firestore เริ่มต้นที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp เริ่มต้น . หากไม่มีอินสแตนซ์ ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น
memoryEagerGarbageCollector() สร้างอินสแตนซ์ของ MemoryEagerGarbageCollector นี่เป็นตัวรวบรวมขยะเริ่มต้นด้วย เว้นแต่จะระบุไว้เป็นอย่างอื่นอย่างชัดเจน
ถาวรMultipleTabManager() สร้างอินสแตนซ์ของ PersistentMultipleTabManager
เซิร์ฟเวอร์ประทับเวลา () ส่งคืน Sentinel ที่ใช้กับ setDoc() หรือ updateDoc() เพื่อรวมการประทับเวลาที่สร้างโดยเซิร์ฟเวอร์ในข้อมูลที่เขียน
ฟังก์ชั่น(databaseId, ...)
getFirestore (รหัสฐานข้อมูล) (เบต้า) ส่งคืนอินสแตนซ์ Firestore ที่มีชื่อที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp เริ่มต้น . หากไม่มีอินสแตนซ์ ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น
ฟังก์ชั่น(องค์ประกอบ, ...)
arrayRemove (องค์ประกอบ) ส่งกลับค่าพิเศษที่สามารถใช้กับ setDoc() หรือบอกให้เซิร์ฟเวอร์ลบองค์ประกอบที่กำหนดออกจากค่าอาร์เรย์ใด ๆ ที่มีอยู่แล้วบนเซิร์ฟเวอร์ อินสแตนซ์ทั้งหมดของแต่ละองค์ประกอบที่ระบุจะถูกลบออกจากอาร์เรย์ หากฟิลด์ที่กำลังแก้ไขไม่ได้เป็นอาร์เรย์ ฟิลด์นั้นจะถูกเขียนทับด้วยอาร์เรย์ว่าง
arrayUnion (องค์ประกอบ) ส่งกลับค่าพิเศษที่สามารถใช้กับ setDoc() หรือ updateDoc() ที่บอกให้เซิร์ฟเวอร์รวมองค์ประกอบที่กำหนดเข้ากับค่าอาร์เรย์ใดๆ ที่มีอยู่แล้วบนเซิร์ฟเวอร์ แต่ละองค์ประกอบที่ระบุที่ไม่มีอยู่ในอาร์เรย์จะถูกเพิ่มที่ส่วนท้าย หากฟิลด์ที่กำลังแก้ไขไม่ได้เป็นอาร์เรย์ ฟิลด์นั้นจะถูกเขียนทับด้วยอาร์เรย์ที่มีองค์ประกอบที่ระบุทุกประการ
ฟังก์ชั่น(ฟิลด์, ...)
เฉลี่ย(สนาม) สร้างวัตถุ AggregateField ที่สามารถใช้เพื่อคำนวณค่าเฉลี่ยของเขตข้อมูลที่ระบุในช่วงของเอกสารในชุดผลลัพธ์ของแบบสอบถาม
ผลรวม (ฟิลด์) สร้างวัตถุ AggregateField ที่สามารถใช้เพื่อคำนวณผลรวมของฟิลด์ที่ระบุในช่วงของเอกสารในชุดผลลัพธ์ของแบบสอบถาม
ฟังก์ชั่น (fieldPath, ... )
orderBy (fieldPath, ทิศทางStr) สร้าง QueryOrderByConstraint ที่เรียงลำดับผลลัพธ์คิวรีตามฟิลด์ที่ระบุ หรือเรียงลำดับจากมากไปน้อยแทนที่จะเรียงลำดับจากน้อยไปหามาก หมายเหตุ: เอกสารที่ไม่มีฟิลด์ที่ระบุจะไม่ปรากฏในผลลัพธ์แบบสอบถาม
โดยที่ (fieldPath, opStr, ค่า) สร้าง QueryFieldFilterConstraint ที่บังคับใช้ว่าเอกสารต้องมีฟิลด์ที่ระบุ และค่าควรเป็นไปตามข้อจำกัดความสัมพันธ์ที่ให้ไว้
ฟังก์ชั่น (ค่าฟิลด์ ... )
endAt (ค่าฟิลด์) สร้าง QueryEndAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้สิ้นสุดที่ฟิลด์ที่ให้ไว้โดยสัมพันธ์กับลำดับของแบบสอบถาม ลำดับของค่าของฟิลด์ต้องตรงกับลำดับของคำสั่งตามคำสั่งย่อยของแบบสอบถาม
endBefore (ค่าฟิลด์) สร้าง QueryEndAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้สิ้นสุดก่อนฟิลด์ที่ให้ไว้โดยสัมพันธ์กับลำดับของแบบสอบถาม ลำดับของค่าของฟิลด์ต้องตรงกับลำดับของคำสั่งตามคำสั่งย่อยของแบบสอบถาม
startAfter (ค่าฟิลด์) สร้าง QueryStartAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้เริ่มต้นหลังจากฟิลด์ที่ให้ไว้โดยสัมพันธ์กับลำดับของการสืบค้น ลำดับของค่าของฟิลด์ต้องตรงกับลำดับของคำสั่งตามคำสั่งย่อยของแบบสอบถาม
startAt (ค่าฟิลด์) สร้าง QueryStartAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้เริ่มต้นที่ฟิลด์ที่ให้ไว้โดยสัมพันธ์กับลำดับของการสืบค้น ลำดับของค่าของฟิลด์ต้องตรงกับลำดับของคำสั่งตามคำสั่งย่อยของแบบสอบถาม
ฟังก์ชั่น (indexManager, ... )
ลบ AllPersistentCacheIndexes (indexManager) ลบดัชนีแคชถาวรทั้งหมด โปรดทราบว่าฟังก์ชันนี้จะลบดัชนีที่สร้างโดย setIndexConfiguration() ซึ่งเลิกใช้งานแล้ว
ปิดการใช้งาน PersistentCacheIndexAutoCreation (indexManager) หยุดการสร้างดัชนีแคชถาวรโดยอัตโนมัติสำหรับการดำเนินการค้นหาในเครื่อง ดัชนีที่สร้างขึ้นโดยการเรียก enablePersistentCacheIndexAutoCreation() ยังคงมีผล
เปิดใช้งาน PersistentCacheIndexAutoCreation (indexManager) เปิดใช้งาน SDK เพื่อสร้างดัชนีแคชถาวรโดยอัตโนมัติสำหรับการดำเนินการค้นหาในเครื่องเมื่อ SDK เชื่อว่าดัชนีแคชสามารถช่วยปรับปรุงประสิทธิภาพได้ คุณลักษณะนี้ถูกปิดใช้งานตามค่าเริ่มต้น
ฟังก์ชั่น(ซ้าย, ...)
รวมFieldEqual (ซ้าย, ขวา) เปรียบเทียบ 'AgggregateField ` กรณีเพื่อความเท่าเทียมกัน
รวม QuerySnapshotEqual (ซ้าย, ขวา) เปรียบเทียบอินสแตนซ์ AggregateQuerySnapshot สองอินสแตนซ์เพื่อความเท่าเทียมกัน AggregateQuerySnapshot สองอินสแตนซ์จะถือว่า "เท่ากัน" หากมีการสืบค้นพื้นฐานที่เปรียบเทียบเท่ากันและข้อมูลเดียวกัน
แบบสอบถามเท่ากับ (ซ้าย, ขวา) คืนค่าเป็นจริงหากแบบสอบถามที่ระบุชี้ไปที่คอลเลกชันเดียวกันและใช้ข้อจำกัดเดียวกัน
การอ้างอิง (ซ้าย, ขวา) คืนค่าเป็นจริงหากการอ้างอิงที่ระบุมีค่าเท่ากัน
สแน็ปช็อตเท่ากับ (ซ้าย, ขวา) คืนค่าเป็นจริงหากสแน็ปช็อตที่ระบุมีค่าเท่ากัน
ฟังก์ชั่น(จำกัด,...)
ขีดจำกัด(ขีดจำกัด) สร้าง QueryLimitConstraint ที่ส่งคืนเอกสารแรกที่ตรงกันเท่านั้น
ขีดจำกัด ToLast (ขีดจำกัด) สร้าง QueryLimitConstraint ที่ส่งคืนเฉพาะเอกสารที่ตรงกันล่าสุดเท่านั้น คุณต้องระบุอย่างน้อยหนึ่งส่วนคำ orderBy สำหรับการสืบค้น limitToLast มิฉะนั้น ข้อยกเว้นจะเกิดขึ้นระหว่างการดำเนินการ
ฟังก์ชั่น (logLevel, ... )
setLogLevel (ระดับบันทึก) ตั้งค่ารายละเอียดของบันทึก Cloud Firestore (แก้ไขข้อบกพร่อง ข้อผิดพลาด หรือไม่มีการโต้ตอบ)
ฟังก์ชั่น(n, ...)
เพิ่มขึ้น(n) ส่งกลับค่าพิเศษที่สามารถใช้กับ setDoc() หรือ updateDoc() ที่บอกให้เซิร์ฟเวอร์เพิ่มค่าปัจจุบันของฟิลด์ตามค่าที่กำหนด หากค่าตัวถูกดำเนินการหรือค่าฟิลด์ปัจจุบันใช้ความแม่นยำของจุดลอยตัว เลขคณิตทั้งหมดจะเป็นไปตามซีแมนทิกส์ IEEE 754 หากทั้งสองค่าเป็นจำนวนเต็ม ค่าที่อยู่นอกช่วงตัวเลขที่ปลอดภัยของ JavaScript ( Number.MIN_SAFE_INTEGER ถึง Number.MAX_SAFE_INTEGER ) ก็อาจสูญเสียความแม่นยำได้เช่นกัน นอกจากนี้ เมื่อประมวลผลโดยแบ็กเอนด์ Firestore แล้ว การดำเนินการจำนวนเต็มทั้งหมดจะถูกจำกัดระหว่าง -2^63 ถึง 2^63-1 หากค่าฟิลด์ปัจจุบันไม่ใช่ประเภท number หรือหากยังไม่มีฟิลด์ การแปลงจะตั้งค่าฟิลด์เป็นค่าที่กำหนด
ฟังก์ชั่น (แบบสอบถาม, ... )
getAggregateFromServer (แบบสอบถาม, รวม Spec) คำนวณการรวมที่ระบุบนเอกสารในชุดผลลัพธ์ของการสืบค้นที่กำหนดโดยไม่ต้องดาวน์โหลดเอกสารจริงๆ การใช้ฟังก์ชันนี้เพื่อดำเนินการรวมกลุ่มมีประสิทธิภาพเนื่องจากมีการดาวน์โหลดเฉพาะค่าการรวมสุดท้ายเท่านั้น ไม่ใช่ข้อมูลของเอกสาร ฟังก์ชันนี้สามารถดำเนินการรวมเอกสารในกรณีที่ชุดผลลัพธ์มีขนาดใหญ่จนไม่สามารถดาวน์โหลดทั้งหมดได้ (เอกสารนับพัน) ผลลัพธ์ที่ได้รับจากเซิร์ฟเวอร์จะถูกนำเสนอโดยไม่มีการเปลี่ยนแปลง โดยไม่คำนึงถึงสถานะท้องถิ่นใดๆ นั่นคือเอกสารในแคชในเครื่องจะไม่ถูกนำมาพิจารณา และการแก้ไขในเครื่องยังไม่ซิงโครไนซ์กับเซิร์ฟเวอร์ ผลลัพธ์ที่ดาวน์โหลดก่อนหน้านี้ (ถ้ามี) จะไม่ถูกนำมาใช้ การเรียกใช้ฟังก์ชันนี้ทุกครั้งจำเป็นต้องเกี่ยวข้องกับการเดินทางไปกลับไปยังเซิร์ฟเวอร์
getCountFromServer (แบบสอบถาม) คำนวณจำนวนเอกสารในชุดผลลัพธ์ของการสืบค้นที่กำหนดโดยไม่ต้องดาวน์โหลดเอกสารจริง การใช้ฟังก์ชันนี้ในการนับเอกสารมีประสิทธิภาพเนื่องจากมีการดาวน์โหลดเฉพาะการนับครั้งสุดท้าย ไม่ใช่ข้อมูลของเอกสาร ฟังก์ชั่นนี้สามารถนับเอกสารในกรณีที่ชุดผลลัพธ์มีขนาดใหญ่จนต้องดาวน์โหลดทั้งหมด (เอกสารนับพัน) ผลลัพธ์ที่ได้รับจากเซิร์ฟเวอร์จะถูกนำเสนอโดยไม่มีการเปลี่ยนแปลง โดยไม่คำนึงถึงสถานะท้องถิ่นใดๆ นั่นคือเอกสารในแคชในเครื่องจะไม่ถูกนำมาพิจารณา และการแก้ไขในเครื่องยังไม่ซิงโครไนซ์กับเซิร์ฟเวอร์ ผลลัพธ์ที่ดาวน์โหลดก่อนหน้านี้ (ถ้ามี) จะไม่ถูกนำมาใช้ การเรียกใช้ฟังก์ชันนี้ทุกครั้งจำเป็นต้องเกี่ยวข้องกับการเดินทางไปกลับไปยังเซิร์ฟเวอร์
getDocs(แบบสอบถาม) ดำเนินการค้นหาและส่งกลับผลลัพธ์เป็น QuerySnapshot หมายเหตุ: getDocs() พยายามจัดเตรียมข้อมูลล่าสุดเมื่อเป็นไปได้โดยการรอข้อมูลจากเซิร์ฟเวอร์ แต่อาจส่งคืนข้อมูลที่แคชไว้หรือล้มเหลวหากคุณออฟไลน์และไม่สามารถเข้าถึงเซิร์ฟเวอร์ได้ หากต้องการระบุลักษณะการทำงานนี้ ให้เรียกใช้ getDocsFromCache() หรือ getDocsFromServer() .
getDocsFromCache(แบบสอบถาม) ดำเนินการค้นหาและส่งกลับผลลัพธ์เป็น QuerySnapshot จากแคช ส่งคืนชุดผลลัพธ์ที่ว่างเปล่าหากไม่มีเอกสารที่ตรงกับแบบสอบถามถูกแคชไว้ในปัจจุบัน
getDocsFromServer (แบบสอบถาม) ดำเนินการค้นหาและส่งกลับผลลัพธ์เป็น QuerySnapshot จากเซิร์ฟเวอร์ ส่งกลับข้อผิดพลาดหากเครือข่ายไม่พร้อมใช้งาน
onSnapshot (แบบสอบถาม ผู้สังเกตการณ์) แนบตัวฟังสำหรับเหตุการณ์ QuerySnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error Listener สามารถยกเลิกได้โดยการเรียกใช้ฟังก์ชันที่ส่งคืนเมื่อมีการเรียกใช้ onSnapshot หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
onSnapshot(แบบสอบถาม ตัวเลือก ผู้สังเกตการณ์) แนบตัวฟังสำหรับเหตุการณ์ QuerySnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error Listener สามารถยกเลิกได้โดยการเรียกใช้ฟังก์ชันที่ส่งคืนเมื่อมีการเรียกใช้ onSnapshot หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
onSnapshot (แบบสอบถาม, onNext, onError, onCompletion) แนบตัวฟังสำหรับเหตุการณ์ QuerySnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error Listener สามารถยกเลิกได้โดยการเรียกใช้ฟังก์ชันที่ส่งคืนเมื่อมีการเรียกใช้ onSnapshot หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
onSnapshot (แบบสอบถาม, ตัวเลือก, onNext, onError, onCompletion) แนบตัวฟังสำหรับเหตุการณ์ QuerySnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error Listener สามารถยกเลิกได้โดยการเรียกใช้ฟังก์ชันที่ส่งคืนเมื่อมีการเรียกใช้ onSnapshot หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
แบบสอบถาม (แบบสอบถาม, ตัวกรองคอมโพสิต, ข้อ จำกัด แบบสอบถาม) สร้างอินสแตนซ์ใหม่ของ แบบสอบถาม ที่ไม่เปลี่ยนรูปแบบซึ่งขยายเพื่อรวมข้อจำกัดแบบสอบถามเพิ่มเติมด้วย
แบบสอบถาม (แบบสอบถาม, ข้อ จำกัด ของแบบสอบถาม) สร้างอินสแตนซ์ใหม่ของ แบบสอบถาม ที่ไม่เปลี่ยนรูปแบบซึ่งขยายเพื่อรวมข้อจำกัดแบบสอบถามเพิ่มเติมด้วย
ฟังก์ชั่น (queryConstraints, ... )
และ (ข้อจำกัดแบบสอบถาม) สร้าง QueryCompositeFilterConstraint ใหม่ที่เป็นการรวมข้อจำกัดของตัวกรองที่กำหนด ตัวกรองร่วมจะรวมเอกสารไว้ด้วยหากเป็นไปตามตัวกรองที่กำหนดทั้งหมด
หรือ (ข้อจำกัดแบบสอบถาม) สร้าง QueryCompositeFilterConstraint ใหม่ที่เป็นการแยกจากข้อจำกัดตัวกรองที่กำหนด ตัวกรองการแยกส่วนจะรวมเอกสารด้วยหากเป็นไปตามตัวกรองใดๆ ที่กำหนด
ฟังก์ชั่น(อ้างอิง, ...)
addDoc(ข้อมูลอ้างอิง) เพิ่มเอกสารใหม่ให้กับ CollectionReference ที่ระบุด้วยข้อมูลที่กำหนด โดยกำหนด ID เอกสารให้โดยอัตโนมัติ
คอลเลกชัน (อ้างอิง เส้นทาง พาธเซ็กเมนต์) รับอินสแตนซ์ CollectionReference ที่อ้างถึงคอลเลกชันย่อยของ reference ที่เส้นทางสัมพัทธ์ที่ระบุ
คอลเลกชัน (อ้างอิง เส้นทาง พาธเซ็กเมนต์) รับอินสแตนซ์ CollectionReference ที่อ้างถึงคอลเลกชันย่อยของ reference ที่เส้นทางสัมพัทธ์ที่ระบุ
ลบDoc(อ้างอิง) ลบเอกสารที่อ้างถึงโดย DocumentReference ที่ระบุ
doc(อ้างอิง, เส้นทาง, pathSegments) รับอินสแตนซ์ DocumentReference ที่อ้างถึงเอกสารภายใน reference ที่เส้นทางสัมพัทธ์ที่ระบุ หากไม่มีการระบุเส้นทาง ระบบจะใช้ ID เฉพาะที่สร้างขึ้นโดยอัตโนมัติสำหรับ DocumentReference ที่ส่งคืน
doc(อ้างอิง, เส้นทาง, pathSegments) รับอินสแตนซ์ DocumentReference ที่อ้างถึงเอกสารภายใน reference ที่เส้นทางสัมพัทธ์ที่ระบุ
getDoc (อ้างอิง) อ่านเอกสารที่อ้างถึงโดย DocumentReference นี้ หมายเหตุ: getDoc() พยายามจัดเตรียมข้อมูลล่าสุดเมื่อเป็นไปได้โดยการรอข้อมูลจากเซิร์ฟเวอร์ แต่อาจส่งคืนข้อมูลที่แคชไว้หรือล้มเหลวหากคุณออฟไลน์และไม่สามารถเข้าถึงเซิร์ฟเวอร์ได้ หากต้องการระบุลักษณะการทำงานนี้ ให้เรียกใช้ getDocFromCache() หรือ getDocFromServer() .
getDocFromCache (อ้างอิง) อ่านเอกสารที่อ้างถึงโดย DocumentReference นี้จากแคช ส่งกลับข้อผิดพลาดหากเอกสารไม่ได้ถูกแคชในปัจจุบัน
getDocFromServer (ข้อมูลอ้างอิง) อ่านเอกสารที่อ้างถึงโดย DocumentReference นี้จากเซิร์ฟเวอร์ ส่งกลับข้อผิดพลาดหากเครือข่ายไม่พร้อมใช้งาน
onSnapshot (ข้อมูลอ้างอิง ผู้สังเกตการณ์) แนบ Listener สำหรับเหตุการณ์ DocumentSnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
onSnapshot(ข้อมูลอ้างอิง ตัวเลือก ผู้สังเกตการณ์) แนบ Listener สำหรับเหตุการณ์ DocumentSnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
onSnapshot (อ้างอิง, onNext, onError, onCompletion) แนบ Listener สำหรับเหตุการณ์ DocumentSnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
onSnapshot (อ้างอิง, ตัวเลือก, onNext, onError, onCompletion) แนบ Listener สำหรับเหตุการณ์ DocumentSnapshot คุณอาจส่งผ่านการโทรกลับ onNext และ onError แต่ละรายการหรือส่งผ่านวัตถุผู้สังเกตการณ์เพียงรายการเดียวพร้อมกับการโทรกลับ next และ error หมายเหตุ: แม้ว่าจะสามารถจัดให้มีการเรียกกลับ onCompletion ได้ แต่จะไม่มีการเรียกเนื่องจากสตรีมสแน็ปช็อตไม่มีที่สิ้นสุด
setDoc(อ้างอิง ข้อมูล) เขียนไปยังเอกสารที่อ้างถึงโดย DocumentReference นี้ หากยังไม่มีเอกสารก็จะถูกสร้างขึ้น
setDoc(ข้อมูลอ้างอิง ข้อมูล ตัวเลือก) เขียนไปยังเอกสารที่อ้างอิงโดย DocumentReference ที่ระบุ หากยังไม่มีเอกสารก็จะถูกสร้างขึ้น หากคุณระบุ merge หรือ mergeFields ข้อมูลที่ระบุสามารถผสานเข้ากับเอกสารที่มีอยู่ได้
updateDoc(ข้อมูลอ้างอิง ข้อมูล) อัปเดตฟิลด์ในเอกสารที่อ้างถึงโดย DocumentReference ที่ระบุ การอัปเดตจะล้มเหลวหากนำไปใช้กับเอกสารที่ไม่มีอยู่
updateDoc (การอ้างอิง ฟิลด์ ค่า moreFieldsAndValues) อัปเดตฟิลด์ในเอกสารที่อ้างอิงโดย DocumentReference ที่ระบุ การอัปเดตจะล้มเหลวหากนำไปใช้กับเอกสารที่ไม่มีอยู่ ฟิลด์ที่ซ้อนกันสามารถอัปเดตได้โดยการระบุสตริงพาธของฟิลด์ที่คั่นด้วยจุด หรือโดยการจัดเตรียมออบเจ็กต์ FieldPath
ฟังก์ชั่น(การตั้งค่า, ...)
หน่วยความจำ LocalCache (การตั้งค่า) สร้างอินสแตนซ์ของ MemoryLocalCache คุณสามารถตั้งค่าอินสแตนซ์เป็น FirestoreSettings.cache เพื่อบอก SDK ว่าควรใช้เลเยอร์แคชใด
memoryLruGarbageCollector (การตั้งค่า) สร้างอินสแตนซ์ของ MemoryLruGarbageCollector สามารถระบุขนาดเป้าหมายเป็นส่วนหนึ่งของพารามิเตอร์การตั้งค่าได้ ตัวรวบรวมจะเริ่มการลบเอกสารเมื่อขนาดแคชเกินขนาดที่กำหนด ขนาดแคชเริ่มต้นคือ 40MB (40 * 1024 * 1024 ไบต์)
ถาวร LocalCache (การตั้งค่า) สร้างอินสแตนซ์ของ PersistentLocalCache คุณสามารถตั้งค่าอินสแตนซ์เป็น FirestoreSettings.cache เพื่อบอก SDK ว่าควรใช้เลเยอร์แคชใด ไม่สามารถใช้แคชถาวรในสภาพแวดล้อม Node.js
ถาวร SingleTabManager (การตั้งค่า) สร้างอินสแตนซ์ของ PersistentSingleTabManager
ฟังก์ชั่น (สแนปช็อต, ... )
สิ้นสุดที่ (ภาพรวม) สร้าง QueryEndAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้สิ้นสุดที่เอกสารที่ให้มา (รวม) ตำแหน่งสิ้นสุดจะสัมพันธ์กับลำดับของแบบสอบถาม เอกสารจะต้องมีฟิลด์ทั้งหมดที่ระบุไว้ใน orderBy ของแบบสอบถาม
สิ้นสุดก่อน (ภาพรวม) สร้าง QueryEndAtConstraint ที่แก้ไขชุดผลลัพธ์ให้สิ้นสุดก่อนเอกสารที่ให้มา (พิเศษ) ตำแหน่งสิ้นสุดจะสัมพันธ์กับลำดับของแบบสอบถาม เอกสารจะต้องมีฟิลด์ทั้งหมดที่ระบุไว้ใน orderBy ของแบบสอบถาม
startAfter (ภาพรวม) สร้าง QueryStartAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้เริ่มต้นหลังจากเอกสารที่ให้มา (เฉพาะ) ตำแหน่งเริ่มต้นจะสัมพันธ์กับลำดับของแบบสอบถาม เอกสารจะต้องมีฟิลด์ทั้งหมดที่ระบุไว้ใน orderBy ของแบบสอบถาม
startAt (ภาพรวม) สร้าง QueryStartAtConstraint ที่ปรับเปลี่ยนชุดผลลัพธ์ให้เริ่มต้นที่เอกสารที่ให้มา (รวม) ตำแหน่งเริ่มต้นจะสัมพันธ์กับลำดับของแบบสอบถาม เอกสารจะต้องมีฟิลด์ทั้งหมดที่ระบุไว้ใน orderBy ของแบบสอบถามนี้

ชั้นเรียน

ระดับ คำอธิบาย
สนามรวม แสดงถึงการรวมกลุ่มที่ Firestore สามารถทำได้
AggregateQuerySnapshot ผลลัพธ์ของการดำเนินการแบบสอบถามแบบรวม
ไบต์ วัตถุที่ไม่เปลี่ยนรูปซึ่งแสดงถึงอาร์เรย์ของไบต์
คอลเลกชันอ้างอิง สามารถใช้ออบเจ็กต์ CollectionReference ในการเพิ่มเอกสาร รับการอ้างอิงเอกสาร และการสืบค้นเอกสาร (โดยใช้ query() ).
เอกสารอ้างอิง DocumentReference อ้างอิงถึงตำแหน่งของเอกสารในฐานข้อมูล Firestore และสามารถใช้เพื่อเขียน อ่าน หรือฟังตำแหน่งนั้นได้ เอกสารที่ตำแหน่งอ้างอิงอาจมีหรือไม่มีก็ได้
DocumentSnapshot DocumentSnapshot มีข้อมูลที่อ่านจากเอกสารในฐานข้อมูล Firestore ของคุณ สามารถดึงข้อมูลด้วย .data() หรือ .get(<field>) เพื่อรับฟิลด์เฉพาะ สำหรับ DocumentSnapshot ที่ชี้ไปยังเอกสารที่ไม่มีอยู่ การเข้าถึงข้อมูลใดๆ จะส่งกลับค่า 'ไม่ได้กำหนด' คุณสามารถใช้เมธอด exists() เพื่อตรวจสอบการมีอยู่ของเอกสารได้อย่างชัดเจน
FieldPath FieldPath อ้างถึงเขตข้อมูลในเอกสาร เส้นทางอาจประกอบด้วยชื่อฟิลด์เดียว (อ้างอิงถึงฟิลด์ระดับบนสุดในเอกสาร) หรือรายการชื่อฟิลด์ (อ้างอิงถึงฟิลด์ที่ซ้อนกันในเอกสาร) สร้าง FieldPath โดยระบุชื่อฟิลด์ หากมีการระบุชื่อฟิลด์มากกว่าหนึ่งชื่อ เส้นทางจะชี้ไปยังฟิลด์ที่ซ้อนกันในเอกสาร
ค่าฟิลด์ ค่า Sentinel ที่สามารถใช้ได้เมื่อเขียนช่องเอกสารด้วย set() หรือ update()
ร้านดับเพลิง อินเทอร์เฟซบริการ Cloud Firestore อย่าเรียกตัวสร้างนี้โดยตรง ให้ใช้ getFirestore() แทน .
ข้อผิดพลาดของ Firestore ข้อผิดพลาดที่ส่งคืนโดยการดำเนินการ Firestore
จีโอพอยต์ วัตถุที่ไม่เปลี่ยนรูปซึ่งแสดงถึงที่ตั้งทางภูมิศาสตร์ใน Firestore ตำแหน่งจะแสดงเป็นคู่ละติจูด/ลองจิจูด ค่าละติจูดอยู่ในช่วง [-90, 90] ค่าลองจิจูดอยู่ในช่วง [-180, 180]
LoadBundleTask แสดงถึงงานในการโหลดบันเดิล Firestore โดยแสดงความคืบหน้าของการโหลดบันเดิล ตลอดจนการทำงานให้เสร็จสิ้นและเหตุการณ์ข้อผิดพลาด API เข้ากันได้กับ Promise<LoadBundleTaskProgress>
ตัวจัดการแคชดัชนีถาวร PersistentCacheIndexManager สำหรับการกำหนดค่าดัชนีแคชถาวรที่ใช้สำหรับการดำเนินการค้นหาในเครื่อง หากต้องการใช้ ให้เรียก getPersistentCacheIndexManager() เพื่อรับอินสแตนซ์
แบบสอบถาม Query หมายถึงแบบสอบถามที่คุณสามารถอ่านหรือฟังได้ คุณยังสามารถสร้างออบเจ็กต์ Query ที่ปรับปรุงแล้วได้โดยการเพิ่มตัวกรองและการเรียงลำดับ
QueryCompositeFilterConstraint QueryCompositeFilterConstraint ใช้เพื่อจำกัดชุดของเอกสารที่ส่งคืนโดยแบบสอบถาม Firestore โดยดำเนินการตรรกะ OR หรือ AND ของ QueryFieldFilterConstraint หลายรายการ s หรือ QueryCompositeFilterConstraint ส. QueryCompositeFilterConstraint s ถูกสร้างขึ้นโดยการเรียกใช้ or() หรือ and() จากนั้นสามารถส่งผ่านไปยัง query() เพื่อสร้างอินสแตนซ์เคียวรีใหม่ที่มี QueryCompositeFilterConstraint ด้วย
ข้อจำกัดแบบสอบถาม QueryConstraint ใช้เพื่อจำกัดชุดเอกสารที่ส่งคืนโดยแบบสอบถาม Firestore QueryConstraint s ถูกสร้างขึ้นโดยการเรียกใช้ โดยที่ () , สั่งโดย() , เริ่มต้นที่() , startAfter() , สิ้นสุดก่อน() , สิ้นสุดที่() , ขีดจำกัด() , LimitToLast() จากนั้นสามารถส่งผ่านไปยัง query() เพื่อสร้างอินสแตนซ์การสืบค้นใหม่ที่มี QueryConstraint นี้ด้วย
QueryDocumentSnapshot QueryDocumentSnapshot มีข้อมูลที่อ่านจากเอกสารในฐานข้อมูล Firestore ของคุณโดยเป็นส่วนหนึ่งของแบบสอบถาม รับประกันว่าเอกสารจะมีอยู่จริงและสามารถแยกข้อมูลด้วย .data() หรือ .get(<field>) เพื่อรับฟิลด์เฉพาะ QueryDocumentSnapshot นำเสนอพื้นผิว API เดียวกันกับ DocumentSnapshot เนื่องจากผลลัพธ์การสืบค้นมีเพียงเอกสารที่มีอยู่ คุณสมบัติ exists จึงเป็นจริงเสมอ และ data() จะไม่ส่งคืน 'unknown'
QueryEndAtConstraint QueryEndAtConstraint ใช้เพื่อแยกเอกสารออกจากส่วนท้ายของชุดผลลัพธ์ที่ส่งคืนโดยแบบสอบถาม Firestore QueryEndAtConstraint ถูกสร้างขึ้นโดยการเรียกใช้ endAt() หรือ endBefore() จากนั้นสามารถส่งผ่านไปยัง query() เพื่อสร้างอินสแตนซ์เคียวรีใหม่ที่มี QueryEndAtConstraint นี้ด้วย
QueryFieldFilterConstraint QueryFieldFilterConstraint ใช้เพื่อจำกัดชุดเอกสารที่ส่งคืนโดยแบบสอบถาม Firestore โดยการกรองในช่องเอกสารอย่างน้อย 1 ช่อง QueryFieldFilterConstraint ถูกสร้างขึ้นโดยการเรียกใช้ Where() จากนั้นสามารถส่งผ่านไปยัง Query() เพื่อสร้างอินสแตนซ์การสืบค้นใหม่ที่มี QueryFieldFilterConstraint นี้ด้วย
แบบสอบถามจำกัดข้อจำกัด QueryLimitConstraint ใช้เพื่อจำกัดจำนวนเอกสารที่ส่งคืนโดยแบบสอบถาม Firestore QueryLimitConstraint ถูกสร้างขึ้นโดยการเรียกใช้ Limit() หรือ LimitToLast() จากนั้นสามารถส่งผ่านไปยัง Query() เพื่อสร้างอินสแตนซ์เคียวรีใหม่ที่มี QueryLimitConstraint นี้ด้วย
QueryOrderByConstraint QueryOrderByConstraint ใช้เพื่อจัดเรียงชุดเอกสารที่ส่งคืนโดยแบบสอบถาม Firestore QueryOrderByConstraint S ถูกสร้างขึ้นโดยการเรียกใช้ orderby () และจากนั้นสามารถส่งผ่านไปยัง Query () เพื่อสร้างอินสแตนซ์แบบสอบถามใหม่ที่มี QueryOrderByConstraint นี้ หมายเหตุ: เอกสารที่ไม่มีฟิลด์ ORDERBY จะไม่ปรากฏในผลลัพธ์การสืบค้น
QuerySnapShot QuerySnapshot มีเอกสารศูนย์หรือมากกว่าวัตถุ DocumentSnapshot ที่แสดงผลลัพธ์ของการสืบค้น เอกสารสามารถเข้าถึงได้เป็นอาร์เรย์ผ่านคุณสมบัติ docs หรือแจกแจงโดยใช้วิธี forEach จำนวนเอกสารสามารถกำหนดได้ผ่านคุณสมบัติ empty และ size
QueryStartAtConstraint QueryStartAtConstraint ใช้เพื่อแยกเอกสารออกจากจุดเริ่มต้นของชุดผลลัพธ์ที่ส่งคืนโดยแบบสอบถาม Firestore QueryStartAtConstraint S ถูกสร้างขึ้นโดยการเรียกใช้ StartAt () หรือ startAfter () และจากนั้นสามารถส่งผ่านไปยัง Query () เพื่อสร้างอินสแตนซ์แบบสอบถามใหม่ที่มี QueryStartAtConstraint นี้
Snapshotmetadata ข้อมูลเมตาเกี่ยวกับภาพรวมอธิบายสถานะของภาพรวม
การประทับเวลา Timestamp แสดงถึงจุดในเวลาที่เป็นอิสระจากเขตเวลาหรือปฏิทินใด ๆ แสดงเป็นวินาทีและเศษส่วนของวินาทีที่ความละเอียดนาโนวินาทีในเวลา UTC Epoch มันถูกเข้ารหัสโดยใช้ปฏิทิน Gregorian Proleptic ซึ่งขยายปฏิทิน Gregorian ย้อนหลังไปถึงปีที่หนึ่ง มันถูกเข้ารหัสโดยสมมติว่าทุกนาทีมีความยาว 60 วินาทีเช่นการกระโดดครั้งวินาทีคือ "เปื้อน" เพื่อไม่ต้องกระโดดตารางที่สองสำหรับการตีความ ช่วงตั้งแต่ 0001-01-01T00: 00: 00Z ถึง 9999-12-31T23: 59: 59.999999999Z ตัวอย่างและข้อมูลจำเพาะเพิ่มเติมโปรดดู คำจำกัดความของการประทับเวลา .
ธุรกรรม การอ้างอิงถึงธุรกรรม วัตถุ Transaction ที่ส่งผ่านไปยัง updateFunction ของธุรกรรมให้วิธีการอ่านและเขียนข้อมูลภายในบริบทการทำธุรกรรม ดู RunTransaction () .
batch ชุดการเขียนที่ใช้ในการดำเนินการหลายการเขียนเป็นหน่วยอะตอมเดียว สามารถรับวัตถุ WriteBatch ได้โดยการเรียก writebatch () . มันมีวิธีการสำหรับการเพิ่มการเขียนลงในชุดการเขียน ไม่มีการเขียนใด ๆ ที่จะกระทำ (หรือมองเห็นได้ในท้องถิ่น) จนกว่าจะมีการเรียกว่า writebatch.commit ()

อินเทอร์เฟซ

อินเตอร์เฟซ คำอธิบาย
การรวม ระบุชุดของการรวมและนามแฝงของพวกเขา
DocumentChange DocumentChange แสดงถึงการเปลี่ยนแปลงเอกสารที่ตรงกับแบบสอบถาม มันมีเอกสารที่ได้รับผลกระทบและประเภทของการเปลี่ยนแปลงที่เกิดขึ้น
documentdata ข้อมูลเอกสาร (สำหรับใช้กับ setDoc () ) ประกอบด้วยฟิลด์ที่แมปกับค่า
Experimentallongpollingoptions ตัวเลือกที่กำหนดค่าการขนส่งเครือข่ายพื้นฐานของ SDK (WebChannel) เมื่อใช้งานยาว หมายเหตุ: อินเทอร์เฟซนี้คือ "การทดลอง" และอาจมีการเปลี่ยนแปลง ดู FirestoreSettings.experimentalAutoDetectLongPolling , FirestoreSettings.experimentalForceLongPolling และ FirestoreSettings.experimentalLongPollingOptions
FirestoredataConverter ตัวแปลงที่ใช้โดย withConverter() เพื่อแปลงวัตถุผู้ใช้ประเภท AppModelType เป็นข้อมูล firestore ของประเภท DbModelType การใช้ตัวแปลงช่วยให้คุณสามารถระบุอาร์กิวเมนต์ประเภททั่วไปเมื่อจัดเก็บและดึงวัตถุจาก Firestore ในบริบทนี้ "AppModel" เป็นคลาสที่ใช้ในแอปพลิเคชันเพื่อจัดทำข้อมูลและฟังก์ชั่นที่เกี่ยวข้องเข้าด้วยกัน ยกตัวอย่างเช่นคลาสดังกล่าวอาจมีคุณสมบัติที่มีประเภทข้อมูลที่ซับซ้อน, ซ้อน, คุณสมบัติที่ใช้สำหรับการบันทึกความทรงจำคุณสมบัติของประเภทที่ไม่ได้รับการสนับสนุนโดย Firestore (เช่น symbol และ bigint ) และฟังก์ชั่นผู้ช่วยที่ดำเนินการผสม คลาสดังกล่าวไม่เหมาะสมและ/หรือเป็นไปได้ที่จะเก็บไว้ในฐานข้อมูล Firestore อินสแตนซ์ของชั้นเรียนดังกล่าวจะต้องถูกแปลงเป็น "วัตถุจาวาสคริปต์เก่า ๆ " (POJOS) ที่มีคุณสมบัติดั้งเดิมโดยเฉพาะซึ่งอาจซ้อนอยู่ใน pojos อื่น ๆ หรืออาร์เรย์ของ pojos ในบริบทนี้ประเภทนี้เรียกว่า "DBModel" และจะเป็นวัตถุที่เหมาะสมสำหรับการคงอยู่ใน Firestore เพื่อความสะดวกแอพพลิเคชั่นสามารถใช้ FirestoreDataConverter และลงทะเบียนตัวแปลงด้วยวัตถุ Firestore เช่น DocumentReference หรือ Query เพื่อแปลง AppModel เป็น DbModel โดยอัตโนมัติเมื่อจัดเก็บเป็น Firestore และแปลง DbModel เป็น AppModel เมื่อดึงออกจาก Firestore
Firestoresettings ระบุการกำหนดค่าที่กำหนดเองสำหรับอินสแตนซ์ Cloud Firestore ของคุณ คุณต้องตั้งค่าเหล่านี้ก่อนที่จะเรียกใช้วิธีอื่นใด ๆ
ดัชนี (เบต้า) คำจำกัดความ SDK ของดัชนีไฟร์สโตร์
การกำหนดค่าดัชนี (เบต้า) รายการดัชนี Firestore เพื่อเพิ่มความเร็วในการดำเนินการค้นหาในท้องถิ่น ดู รูปแบบ JSON สำหรับคำอธิบายของรูปแบบของคำจำกัดความดัชนี
ฟีลด์ดัชนี (เบต้า) องค์ประกอบฟิลด์เดียวในการกำหนดค่าดัชนี
loadbundletaskprogress แสดงถึงการอัปเดตความคืบหน้าหรือสถานะสุดท้ายจากการโหลดชุด
MemoryCachesettings วัตถุการตั้งค่าเพื่อกำหนดค่าอินสแตน MemoryLocalCache
Memoryeagerbagecollector นักสะสมขยะจะลบเอกสารเมื่อใดก็ตามที่พวกเขาไม่ได้เป็นส่วนหนึ่งของการสืบค้นที่ใช้งานอยู่และไม่มีการกลายพันธุ์ในท้องถิ่นที่แนบมากับพวกเขา นักสะสมนี้พยายามที่จะให้แน่ใจว่ารอยเท้าหน่วยความจำต่ำสุดจาก SDK ที่มีความเสี่ยงของเอกสารที่ไม่ได้ถูกแคชสำหรับการสืบค้นออฟไลน์หรือสำหรับการสืบค้นโดยตรงไปยังแคช ใช้ฟังก์ชั่นโรงงานเพื่อสร้างอินสแตนซ์ของนักสะสมนี้
MemoryLocalcache จัดเตรียมแคชในหน่วยความจำให้กับ SDK นี่คือแคชเริ่มต้นเว้นแต่จะได้รับการกำหนดค่าอย่างชัดเจนเป็นอย่างอื่น หากต้องการใช้ให้สร้างอินสแตนซ์โดยใช้ฟังก์ชั่นโรงงานจากนั้นตั้งค่าอินสแตนซ์เป็น FirestoreSettings.cache และเรียก initializeFirestore โดยใช้วัตถุการตั้งค่า
หน่วยความจำ นักสะสมขยะลบเอกสารที่ใช้น้อยที่สุดในหลายชุด ตัวสะสมนี้ได้รับการกำหนดค่าด้วยขนาดเป้าหมายและจะทำการรวบรวมเฉพาะเมื่อเอกสารแคชเกินขนาดเป้าหมาย มันหลีกเลี่ยงการสืบค้นแบ็กเอนด์ซ้ำสำหรับการสืบค้นหรือเอกสารเดียวกันซึ่งเสี่ยงต่อการมีรอยเท้าหน่วยความจำที่ใหญ่ขึ้น ใช้ฟังก์ชั่นโรงงานเพื่อสร้างอินสแตนซ์ของนักสะสมนี้
การคงอยู่ การตั้งค่าที่สามารถส่งผ่านไปยัง enableIndexedDbPersistence() เพื่อกำหนดค่าการคงอยู่ของ Firestore ไม่สามารถใช้การคงอยู่ในสภาพแวดล้อม node.js
PresententCachesettings วัตถุการตั้งค่าเพื่อกำหนดค่าอินสแตนซ์ของ PersistentLocalCache ไม่สามารถใช้แคชแบบถาวรในสภาพแวดล้อม node.js
PresententLocalcache จัดเตรียมแคชถาวรที่ได้รับการสนับสนุนโดย indexedDB ไปยัง SDK หากต้องการใช้ให้สร้างอินสแตนซ์โดยใช้ฟังก์ชั่นโรงงานจากนั้นตั้งค่าอินสแตนซ์เป็น FirestoreSettings.cache และเรียก initializeFirestore โดยใช้วัตถุการตั้งค่า
PresententMultipleTabManager ตัวจัดการแท็บที่รองรับหลายแท็บ SDK จะซิงโครไนซ์แบบสอบถามและการกลายพันธุ์ที่ทำในแท็บทั้งหมดโดยใช้ SDK
PresententsingletabManager ตัวจัดการแท็บรองรับแท็บเดียวเท่านั้นไม่มีการซิงโครไนซ์จะดำเนินการผ่านแท็บ
Presententsingletabmanagersettings พิมพ์เพื่อกำหนดค่าอินสแตนซ์ PersistentSingleTabManager
Snapshotlistenoptions วัตถุตัวเลือกที่สามารถส่งผ่านไปยัง onsnapshot () และ querysnapshot.docchanges () เพื่อควบคุมประเภทของการเปลี่ยนแปลงที่รวมอยู่ในชุดผลลัพธ์
Snapshotoptions ตัวเลือกที่กำหนดค่าวิธีการดึงข้อมูลจาก DocumentSnapshot (ตัวอย่างเช่นพฤติกรรมที่ต้องการสำหรับการประทับเวลาเซิร์ฟเวอร์ที่ยังไม่ได้ตั้งค่าเป็นค่าสุดท้าย)
TransactionOptions ตัวเลือกในการปรับแต่งพฤติกรรมการทำธุรกรรม
ยกเลิกการสมัคร ฟังก์ชั่นที่ส่งคืนโดย onSnapshot() ที่ลบผู้ฟังเมื่อเรียกใช้

ตัวแปร

ตัวแปร คำอธิบาย
cache_size_unlimited ควรใช้อย่างต่อเนื่องเพื่อระบุการรวบรวมขยะ LRU ควรปิดการใช้งาน ตั้งค่านี้เป็น cacheSizeBytes ในการตั้งค่าที่ส่งผ่านไปยังอินสแตนซ์ Firestore

ประเภทนามแฝง

พิมพ์นามแฝง คำอธิบาย
addprefixtokeys ส่งคืนแผนที่ใหม่ที่คีย์ทุกตัวจะถูกนำหน้าด้วยคีย์ด้านนอกต่อท้ายลงใน DOT
รวมฟีลล์ฟิลด์ สหภาพของทุกประเภท AggregateField ที่ได้รับการสนับสนุนจาก Firestore
มวลรวม ประเภทที่คีย์ถูกนำมาจาก AggregateSpec และค่าของค่าที่เป็นผลมาจากการรวมที่ดำเนินการโดย AggregateField ที่สอดคล้องกันจากการ AggregateSpec อินพุต
การรวมตัวกัน ประเภทยูเนี่ยนแทนประเภทรวมที่จะดำเนินการ
ChildUpDateFields ผู้ช่วยสำหรับการคำนวณฟิลด์ซ้อนสำหรับประเภท T1 ที่กำหนด สิ่งนี้จำเป็นเพื่อแจกจ่ายประเภทสหภาพเช่น undefined | {...} (เกิดขึ้นสำหรับอุปกรณ์ประกอบฉากเสริม) หรือ {a: A} | {b: B} ในกรณีการใช้งานนี้ V ใช้เพื่อแจกจ่ายประเภทสหภาพของ T[K] ใน Record เนื่องจาก T[K] ถูกประเมินว่าเป็นการแสดงออกและไม่กระจาย ดู https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
DocumentChanGeType ประเภทของ DocumentChange อาจถูก 'เพิ่ม', 'ลบ' หรือ 'แก้ไข'
FirestoreerrorCode ชุดรหัสสถานะ Firestore รหัสจะเหมือนกันในรหัสที่เปิดเผยโดย GRPC ที่นี่: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md ค่าที่เป็นไปได้: - 'ยกเลิก': การดำเนินการถูกยกเลิก (โดยทั่วไปโดยผู้โทร) - 'ไม่ทราบ': ข้อผิดพลาดที่ไม่รู้จักหรือข้อผิดพลาดจากโดเมนข้อผิดพลาดอื่น - 'argument ไม่ถูกต้อง': ไคลเอนต์ระบุอาร์กิวเมนต์ที่ไม่ถูกต้อง โปรดทราบว่าสิ่งนี้แตกต่างจาก 'เงื่อนไขที่ล้มเหลว' 'argument ไม่ถูกต้อง' หมายถึงอาร์กิวเมนต์ที่มีปัญหาโดยไม่คำนึงถึงสถานะของระบบ (เช่นชื่อฟิลด์ที่ไม่ถูกต้อง) - 'กำหนดเวลา- เกิน': กำหนดเวลาหมดอายุก่อนที่การดำเนินการจะเสร็จสมบูรณ์ สำหรับการดำเนินการที่เปลี่ยนสถานะของระบบข้อผิดพลาดนี้อาจถูกส่งคืนแม้ว่าการดำเนินการจะเสร็จสมบูรณ์ ตัวอย่างเช่นการตอบสนองที่ประสบความสำเร็จจากเซิร์ฟเวอร์อาจล่าช้าไปนานพอที่กำหนดเวลาจะหมดอายุ - 'ไม่พบ': ไม่พบเอกสารที่ร้องขอบางอย่าง - 'มีอยู่แล้ว': เอกสารบางฉบับที่เราพยายามสร้างมีอยู่แล้ว - 'การอนุญาตเบ็นเดอร์': ผู้โทรไม่ได้รับอนุญาตให้ดำเนินการดำเนินการที่ระบุ -'ทรัพยากร-หมด': ทรัพยากรบางอย่างหมดลงบางทีอาจเป็นโควต้าต่อผู้ใช้หรือบางทีระบบไฟล์ทั้งหมดอยู่นอกอวกาศ - 'ความล้มเหลว- เงื่อนไข': การดำเนินการถูกปฏิเสธเนื่องจากระบบไม่ได้อยู่ในสถานะที่จำเป็นสำหรับการดำเนินการของการดำเนินการ - 'ยกเลิก': การดำเนินการถูกยกเลิกโดยทั่วไปเนื่องจากปัญหาพร้อมกันเช่นการทำธุรกรรม ฯลฯ- 'นอกช่วง': การดำเนินการถูกพยายามผ่านช่วงที่ถูกต้อง - 'Unimplemented': การดำเนินการไม่ได้ใช้งานหรือไม่รองรับ/เปิดใช้งาน - 'ภายใน': ข้อผิดพลาดภายใน หมายถึงค่าคงที่บางอย่างที่คาดหวังโดยระบบพื้นฐานได้ถูกทำลาย หากคุณเห็นข้อผิดพลาดอย่างใดอย่างหนึ่งเหล่านี้มีบางอย่างเสียมาก - 'ไม่พร้อมใช้งาน': บริการไม่พร้อมใช้งานในขณะนี้ นี่น่าจะเป็นเงื่อนไขชั่วคราวและอาจได้รับการแก้ไขโดยการลองใหม่ด้วย backoff - 'การสูญเสียข้อมูล': การสูญเสียข้อมูลที่ไม่สามารถกู้คืนได้หรือการทุจริต - 'ไม่ได้รับการรับรอง': คำขอไม่มีข้อมูลรับรองการรับรองความถูกต้องที่ถูกต้องสำหรับการดำเนินการ
Firestorelocalcache ประเภทยูเนี่ยนจากเลเยอร์แคช SDK ที่รองรับทั้งหมด
รับฟัง อธิบายแหล่งที่มาของการสืบค้นรับฟัง ตั้งค่าเป็น default เพื่อฟังทั้งแคชและเซิร์ฟเวอร์เปลี่ยนไป ตั้งค่าเป็น cache เพื่อฟังการเปลี่ยนแปลงในแคชเท่านั้น
Memorygarbagecollector ประเภทยูเนี่ยนจากนักสะสม Gabage ที่สนับสนุนทั้งหมดสำหรับหน่วยความจำในท้องถิ่นแคช
nestedupdatefields สำหรับแต่ละฟิลด์ (เช่น 'bar') ค้นหาคีย์ซ้อนทั้งหมด (เช่น { 'bar.baz': t1, 'bar.qux': t2 } ). ตัดพวกเขาเข้าด้วยกันเพื่อสร้างแผนที่เดียวที่มีคีย์ที่เป็นไปได้ทั้งหมดที่ทำเครื่องหมายว่าเป็นตัวเลือก
OrderByDirection ทิศทางของข้อ สั่งซื้อ () ระบุว่าเป็น 'desc' หรือ 'asc' (ลงหรือจากน้อยไปมาก)
บางส่วน withfieldValue เช่นเดียวกับ Partial<T> แต่อนุญาตให้ฟิลด์ซ้อนกันถูกละเว้นและ FieldValues ​​จะถูกส่งผ่านเป็นค่าทรัพย์สิน
PresententTabManager สหภาพของผู้จัดการแท็บที่มีอยู่ทั้งหมด
ดั้งเดิม ประเภทดั้งเดิม
QueryConstraintType อธิบายข้อ จำกัด การสืบค้นที่แตกต่างกันที่มีอยู่ใน SDK นี้
QueryFilterConstraint QueryFilterConstraint เป็นประเภทผู้ช่วยสหภาพที่แสดงถึง QueryfieldFilterConstraint และ QueryCompositeFilterConstraint .
queryNonFilterConstraint QueryNonFilterConstraint เป็นประเภทสหภาพผู้ช่วยที่แสดงถึงการสคริสต์คอนสตอร์ซึ่งใช้เพื่อแคบหรือสั่งชุดเอกสาร แต่ไม่ได้กรองอย่างชัดเจนในฟิลด์เอกสาร QueryNonFilterConstraint ถูกสร้างขึ้นโดยการเรียกใช้ orderby () , เริ่มต้นที่() , startfter () , endbefore () , endat () , Limit () หรือ Limittolast () และสามารถส่งผ่านไปยัง Query () เพื่อสร้างอินสแตนซ์แบบสอบถามใหม่ที่มี QueryConstraint
setoptions วัตถุตัวเลือกที่กำหนดค่าพฤติกรรมของ setDoc () และการโทร การโทรเหล่านี้สามารถกำหนดค่าให้ทำการผสานแบบละเอียดแทนที่จะเขียนทับเอกสารเป้าหมายอย่างครบถ้วนโดยการจัด SetOptions merge: true
taskstate แสดงถึงสถานะของงานโหลดมัด ทั้ง 'ข้อผิดพลาด' และ 'ความสำเร็จ' เป็นสถานะที่กำลังจม: งานจะยกเลิกหรือสมบูรณ์และจะไม่มีการอัปเดตอีกต่อไปหลังจากรายงาน
Uniontointersection ได้รับประเภทสหภาพ U = T1 | T2 | ... ส่งคืนประเภทที่ตัดกัน (T1 & T2 & ...) ใช้ประเภทเงื่อนไขการกระจายและการอนุมานจากประเภทเงื่อนไข สิ่งนี้ใช้งานได้เนื่องจากผู้สมัครหลายคนสำหรับตัวแปรประเภทเดียวกันในตำแหน่งที่ตรงกันข้ามกับตัวแปรจะทำให้เกิดการอนุมานประเภทสี่แยก https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/Transform-Union-yType--intersection -พิมพ์
อัปเดต อัปเดตข้อมูล (สำหรับใช้กับ UpdatedOc () ) ที่ประกอบด้วยเส้นทางสนาม (เช่น 'foo' หรือ 'foo.baz') แมปกับค่า ฟิลด์ที่มี DOTS อ้างอิงฟิลด์ซ้อนกันภายในเอกสาร FieldValues ​​สามารถส่งผ่านเป็นค่าทรัพย์สิน
Wherefilterop เงื่อนไขการกรองในประโยค ที่ () ถูกระบุโดยใช้สตริง '& lt;', '& lt; =', '==', '! =', '& gt; =', '& gt;', 'Array-contains' , 'In', 'Array-Contains- ใด ๆ ' และ 'Not-in'
withfieldvalue ช่วยให้ FieldValues ​​ถูกส่งผ่านเป็นค่าทรัพย์สินในขณะที่รักษาความปลอดภัยประเภท

ฟังก์ชั่น (แอพ, ... )

getFirestore (แอพ)

ส่งคืนอินสแตนซ์ Firestore เริ่มต้นที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp ที่ให้ไว้ . หากไม่มีอินสแตนซ์ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น

ลายเซ็น:

export declare function getFirestore(app: FirebaseApp): Firestore;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แอป FirebaseApp อินสแตนซ์ FireBaseAPP ที่อินสแตนซ์ Firestore ที่ส่งคืนนั้นเกี่ยวข้องกับ

ผลตอบแทน:

ร้านดับเพลิง

อินสแตนซ์ Firestore เริ่มต้นของแอพที่ให้ไว้

getFirestore (แอพ, DatabaseID)

API นี้มีให้เป็นตัวอย่างสำหรับนักพัฒนาและอาจเปลี่ยนแปลงตามข้อเสนอแนะที่เราได้รับ อย่าใช้ API นี้ในสภาพแวดล้อมการผลิต

ส่งคืนอินสแตนซ์ Firestore ชื่อที่มีอยู่ซึ่งเกี่ยวข้องกับ FirebaseApp ที่ให้มา . หากไม่มีอินสแตนซ์ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น

ลายเซ็น:

export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แอป FirebaseApp อินสแตนซ์ FireBaseAPP ที่อินสแตนซ์ Firestore ที่ส่งคืนนั้นเกี่ยวข้องกับ
ฐานข้อมูล เชือก ชื่อของฐานข้อมูล

ผลตอบแทน:

ร้านดับเพลิง

อินสแตนซ์ Firestore ที่มีชื่อของแอพที่ให้ไว้

InitializeFirestore (แอพ, การตั้งค่า, DatabaseID)

เริ่มต้นอินสแตนซ์ใหม่ของ Firestore ด้วยการตั้งค่าที่ให้ไว้ สามารถเรียกได้ก่อนฟังก์ชั่นอื่น ๆ รวมถึง getFirestore () . หากการตั้งค่าที่กำหนดเองว่างเปล่าฟังก์ชั่นนี้เทียบเท่ากับการเรียก getFirestore () .

ลายเซ็น:

export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แอป FirebaseApp FireBaseApp ซึ่งอินสแตนซ์ Firestore จะเชื่อมโยงกัน
การตั้งค่า Firestoresettings วัตถุการตั้งค่าเพื่อกำหนดค่าอินสแตนซ์ Firestore
ฐานข้อมูล เชือก ชื่อของฐานข้อมูล

ผลตอบแทน:

ร้านดับเพลิง

อินสแตนซ์ Firestore ที่เริ่มต้นใหม่

ฟังก์ชั่น (Firestore, ... )

ClearIndexedDBPersistence (Firestore)

ล้างที่เก็บข้อมูลถาวร ซึ่งรวมถึงการเขียนที่รอดำเนินการและเอกสารแคช

จะต้องถูกเรียกในขณะที่อินสแตนซ์ Firestore ไม่ได้เริ่มต้น (หลังจากแอปถูกยกเลิกหรือเมื่อแอปเริ่มต้นครั้งแรก) ในการเริ่มต้นฟังก์ชั่นนี้จะต้องเรียกก่อนฟังก์ชั่นอื่น ๆ (นอกเหนือจาก InitializeFirestore () หรือ getFirestore () )). หากอินสแตนซ์ Firestore ยังคงทำงานอยู่สัญญาจะถูกปฏิเสธด้วยรหัสข้อผิดพลาดของ failed-precondition .

ลายเซ็น:

export declare function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อล้างการคงอยู่สำหรับ

ผลตอบแทน:

สัญญา <Void>

Promise ที่ได้รับการแก้ไขเมื่อมีการล้างพื้นที่เก็บข้อมูลถาวร มิฉะนั้นสัญญาจะถูกปฏิเสธด้วยข้อผิดพลาด

คอลเลกชัน (Firestore, Path, Pathsegments)

รับอินสแตนซ์ CollectionReference ที่อ้างถึงคอลเลกชันที่เส้นทางสัมบูรณ์ที่ระบุ

ลายเซ็น:

export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData, DocumentData>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง การอ้างอิงถึงอินสแตนซ์รู Firestore
เส้นทาง เชือก เส้นทางที่คั่นด้วยสแลชไปยังคอลเลกชัน
เส้นทางเดิน สตริง [] ส่วนเส้นทางเพิ่มเติมที่จะใช้สัมพันธ์กับอาร์กิวเมนต์แรก

ผลตอบแทน:

การรวบรวม < documentData , documentdata >

อินสแตนซ์ CollectionReference

ข้อยกเว้น

หากเส้นทางสุดท้ายมีจำนวนเซ็กเมนต์เท่ากันและไม่ชี้ไปที่คอลเลกชัน

CollectionGroup (Firestore, CollectionID)

สร้างและส่งคืนอิน Query แบบสอบถามใหม่ที่มีเอกสารทั้งหมดในฐานข้อมูลที่มีอยู่ในคอลเลกชันหรือการรวบรวมย่อยด้วย collectionId ที่กำหนด .

ลายเซ็น:

export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData, DocumentData>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง การอ้างอิงถึงอินสแตนซ์รู Firestore
ของสะสม เชือก ระบุคอลเลกชันเพื่อสอบถาม ทุกคอลเลกชันหรือ subcollection กับ ID นี้เป็นส่วนสุดท้ายของเส้นทางจะรวมอยู่ด้วย ไม่สามารถมีสแลชได้

ผลตอบแทน:

แบบสอบถาม < documentData , documentdata >

Query ที่สร้างขึ้น .

ConnectFirestoreEmulator (Firestore, โฮสต์, พอร์ต, ตัวเลือก)

ปรับเปลี่ยนอินสแตนซ์นี้เพื่อสื่อสารกับเครื่องจำลองคลาวด์ไฟร์สโคป

ลายเซ็น:

export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
    mockUserToken?: EmulatorMockTokenOptions | string;
}): void;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อกำหนดค่าเพื่อเชื่อมต่อกับตัวจำลอง
เจ้าภาพ เชือก โฮสต์ Emulator (เช่น localhost)
ท่าเรือ ตัวเลข พอร์ต Emulator (เช่น: 9000)
ตัวเลือก {mockusertoken?: emulatormocktokenoptions | เชือก; }

ผลตอบแทน:

เป็นโมฆะ

Disablenetwork (Firestore)

ปิดใช้งานการใช้งานเครือข่ายสำหรับอินสแตนซ์นี้ สามารถเปิดใช้งานได้อีกครั้งผ่าน enableNetwork () . ในขณะที่เครือข่ายถูกปิดใช้งานการโทร snapshot, getDoc() หรือ getDocs() การโทรจะส่งคืนผลลัพธ์จากแคชและการดำเนินการเขียนใด ๆ จะถูกคิวจนกว่าเครือข่ายจะถูกกู้คืน

ลายเซ็น:

export declare function disableNetwork(firestore: Firestore): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง

ผลตอบแทน:

สัญญา <Void>

Promise ที่ได้รับการแก้ไขเมื่อเครือข่ายถูกปิดใช้งาน

หมอ (Firestore, Path, Pathsegments)

รับอินสแตนซ์ DocumentReference ที่อ้างถึงเอกสารที่เส้นทางสัมบูรณ์ที่ระบุ

ลายเซ็น:

export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData, DocumentData>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง การอ้างอิงถึงอินสแตนซ์รู Firestore
เส้นทาง เชือก เส้นทางที่คั่นด้วยสแลชไปยังเอกสาร
เส้นทางเดิน สตริง [] ส่วนเส้นทางเพิ่มเติมที่จะนำไปใช้เมื่อเทียบกับอาร์กิวเมนต์แรก

ผลตอบแทน:

เอกสารเกี่ยวกับเอกสาร < documentData , documentdata >

อินสแตนซ์ DocumentReference

ข้อยกเว้น

หากเส้นทางสุดท้ายมีจำนวนกลุ่มคี่และไม่ชี้ไปที่เอกสาร

enableindexeddbpersistence (Firestore, Presentencesettings)

ฟังก์ชั่นนี้จะถูกลบออกในรุ่นสำคัญในอนาคต ให้ตั้ง FirestoreSettings.localCache เป็นอินสแตนซ์ของ PersistentLocalCache เพื่อเปิดแคช IndexedDB การเรียกใช้ฟังก์ชั่นนี้เมื่อมีการระบุ FirestoreSettings.localCache แล้วจะทำการยกเว้น

พยายามเปิดใช้งานที่เก็บข้อมูลถาวรหากเป็นไปได้

ในความล้มเหลว enableIndexedDbPersistence() จะปฏิเสธสัญญาหรือโยนข้อยกเว้น มีสาเหตุหลายประการที่ทำให้เกิดความล้มเหลวซึ่งสามารถระบุได้ด้วย code ในข้อผิดพลาด

* ความล้มเหลวข้อตกลง: แอพเปิดอยู่แล้วในแท็บเบราว์เซอร์อื่น * Unimplemented: เบราว์เซอร์ไม่เข้ากันกับการใช้งานการคงอยู่แบบออฟไลน์

โปรดทราบว่าแม้หลังจากความล้มเหลวอินสแตนซ์ Firestore จะยังคงใช้งานได้อย่างไรก็ตามการคงอยู่ของออฟไลน์จะถูกปิดใช้งาน

ไม่สามารถใช้การคงอยู่ในสภาพแวดล้อม node.js

ลายเซ็น:

export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อเปิดใช้งานการคงอยู่สำหรับ
การคงอยู่ การคงอยู่ วัตถุการตั้งค่าเพิ่มเติมเพื่อกำหนดค่าการคงอยู่

ผลตอบแทน:

สัญญา <Void>

Promise ที่แสดงถึงการเปิดใช้งานที่เก็บข้อมูลถาวรได้สำเร็จ

enableMultitabIndexedDBPersistence (Firestore)

ฟังก์ชั่นนี้จะถูกลบออกในรุ่นสำคัญในอนาคต ให้ตั้งค่า FirestoreSettings.localCache เป็นอินสแตนซ์ของ PersistentLocalCache เพื่อเปิดแคช IndexedDB การเรียกใช้ฟังก์ชั่นนี้เมื่อมีการระบุ FirestoreSettings.localCache แล้วจะทำการยกเว้น

ความพยายามที่จะเปิดใช้งานที่เก็บข้อมูลแบบถาวรแบบหลายแท็บถ้าเป็นไปได้ หากเปิดใช้งานในทุกแท็บการดำเนินการทั้งหมดจะแชร์การเข้าถึงการคงอยู่ของท้องถิ่นรวมถึงการดำเนินการที่ใช้ร่วมกันของการสืบค้นและการอัปเดตเอกสารท้องถิ่นที่ได้รับการชดเชยเวลาแฝงในทุกอินสแตนซ์ที่เชื่อมต่อทั้งหมด

ในความล้มเหลว enableMultiTabIndexedDbPersistence() จะปฏิเสธสัญญาหรือโยนข้อยกเว้น มีสาเหตุหลายประการที่ทำให้เกิดความล้มเหลวซึ่งสามารถระบุได้ด้วย code ในข้อผิดพลาด

* ความล้มเหลวในการกำหนด: แอพเปิดอยู่แล้วในแท็บเบราว์เซอร์อื่นและไม่ได้เปิดใช้งานหลายแท็บ * Unimplemented: เบราว์เซอร์ไม่เข้ากันกับการใช้งานการคงอยู่แบบออฟไลน์

โปรดทราบว่าแม้หลังจากความล้มเหลวอินสแตนซ์ Firestore จะยังคงใช้งานได้อย่างไรก็ตามการคงอยู่ของออฟไลน์จะถูกปิดใช้งาน

ลายเซ็น:

export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อเปิดใช้งานการคงอยู่สำหรับ

ผลตอบแทน:

สัญญา <Void>

Promise ที่แสดงถึงการเปิดใช้งานที่เก็บข้อมูลถาวรได้สำเร็จ

enableNetwork (Firestore)

เปิดใช้งานการใช้เครือข่ายสำหรับอินสแตนซ์ Firestore นี้อีกครั้งหลังจากการโทรไปยัง disablenetwork ก่อนหน้า () .

ลายเซ็น:

export declare function enableNetwork(firestore: Firestore): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง

ผลตอบแทน:

สัญญา <Void>

Promise ที่ได้รับการแก้ไขเมื่อเปิดใช้งานเครือข่าย

GetPersistentCacheIndexManager (Firestore)

ส่งคืนตัวจัดการดัชนี PersistentCache ที่ใช้โดยวัตถุ Firestore ที่กำหนด

อินสแตนซ์ PersistentCacheIndexManager หรือ null หากไม่ได้ใช้ที่เก็บถาวรในเครื่อง

ลายเซ็น:

export declare function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง

ผลตอบแทน:

PresententCacheIndexManager | โมฆะ

Loadbundle (Firestore, Bundledata)

โหลดชุด Firestore ลงในแคชท้องถิ่น

ลายเซ็น:

export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อโหลดชุดสำหรับ
มัด ReadableStream <Uint8Array> | ArrayBuffer | เชือก วัตถุที่แสดงชุดมัดที่จะโหลด วัตถุที่ถูกต้องคือ ArrayBuffer , ReadableStream<Uint8Array> หรือ string

ผลตอบแทน:

loadbundletask

วัตถุ LoadBundleTask ซึ่งแจ้งผู้โทรด้วยการอัปเดตความคืบหน้าและเหตุการณ์ที่เสร็จสมบูรณ์หรือข้อผิดพลาด มันสามารถใช้เป็น Promise<LoadBundleTaskProgress> .

NamedQuery (Firestore, ชื่อ)

อ่าน แบบสอบถาม Firestore จากแคชท้องถิ่นที่ระบุด้วยชื่อที่กำหนด

แบบสอบถามที่มีชื่อจะถูกบรรจุไว้ในชุดข้อมูลบนฝั่งเซิร์ฟเวอร์ (พร้อมกับเอกสารผลลัพธ์) และโหลดไปยังแคชท้องถิ่นโดยใช้ loadBundle . เมื่ออยู่ในแคชท้องถิ่นให้ใช้วิธีนี้เพื่อแยก แบบสอบถาม ตามชื่อ

ลายเซ็น:

export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่ออ่านแบบสอบถามจาก
ชื่อ เชือก ชื่อของคำถาม

ผลตอบแทน:

สัญญา < คำถาม | null>

Promise ที่ได้รับการแก้ไขด้วยการสืบค้นหรือ null .

Onsnapshotsinsync (Firestore, Observer)

แนบผู้ฟังสำหรับเหตุการณ์สแน็ปช็อตในซิงค์ เหตุการณ์สแน็ปช็อตในซิงค์บ่งชี้ว่าผู้ฟังทั้งหมดที่ได้รับผลกระทบจากการเปลี่ยนแปลงที่กำหนดได้ยิงแม้ว่าการเปลี่ยนแปลงที่สร้างขึ้นจากเซิร์ฟเวอร์เดียวจะส่งผลกระทบต่อผู้ฟังหลายคน

หมายเหตุ: เหตุการณ์สแน็ปช็อตในซิงค์เท่านั้นระบุว่าผู้ฟังจะซิงค์กัน แต่ไม่เกี่ยวข้องกับสแน็ปช็อตเหล่านั้นที่ซิงค์กับเซิร์ฟเวอร์หรือไม่ ใช้ snapshotmetadata ในผู้ฟังแต่ละคนเพื่อตรวจสอบว่าสแน็ปช็อตนั้นมาจากแคชหรือเซิร์ฟเวอร์หรือไม่

ลายเซ็น:

export declare function onSnapshotsInSync(firestore: Firestore, observer: {
    next?: (value: void) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ของ Firestore สำหรับการซิงโครไนซ์สแนปชอต
ผู้สังเกตการณ์ {ถัดไป?: (ค่า: เป็นโมฆะ) => โมฆะ; ข้อผิดพลาด?: (ข้อผิดพลาด: firestoreerror ) => โมฆะ; เสร็จสิ้น?: () => โมฆะ; } วัตถุเดียวที่มีการเรียกคืนข้อผิดพลาด next และ error

ผลตอบแทน:

ยกเลิกการสมัคร

ฟังก์ชั่นยกเลิกการสมัครที่สามารถเรียกให้ยกเลิกการฟังสแน็ปช็อตได้

Onsnapshotsinsync (Firestore, Onsync)

แนบผู้ฟังสำหรับเหตุการณ์สแน็ปช็อตในซิงค์ เหตุการณ์สแน็ปช็อตในซิงค์บ่งชี้ว่าผู้ฟังทั้งหมดที่ได้รับผลกระทบจากการเปลี่ยนแปลงที่กำหนดได้ยิงแม้ว่าการเปลี่ยนแปลงที่สร้างขึ้นจากเซิร์ฟเวอร์เดียวจะส่งผลกระทบต่อผู้ฟังหลายคน

หมายเหตุ: เหตุการณ์สแน็ปช็อตในซิงค์เท่านั้นระบุว่าผู้ฟังจะซิงค์กัน แต่ไม่เกี่ยวข้องกับสแน็ปช็อตเหล่านั้นที่ซิงค์กับเซิร์ฟเวอร์หรือไม่ ใช้ SnapshotMetadata ในผู้ฟังแต่ละคนเพื่อตรวจสอบว่าสแน็ปช็อตนั้นมาจากแคชหรือเซิร์ฟเวอร์หรือไม่

ลายเซ็น:

export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore สำหรับการซิงโครไนซ์สแนปชอต
onsync () => โมฆะ การโทรกลับที่จะเรียกทุกครั้งที่ผู้ฟังสแน็ปช็อตทั้งหมดซิงค์กัน

ผลตอบแทน:

ยกเลิกการสมัคร

ฟังก์ชั่นยกเลิกการสมัครที่สามารถเรียกให้ยกเลิกการฟังสแน็ปช็อตได้

RunTransaction (Firestore, UpdateFunction, ตัวเลือก)

ดำเนินการ updateFunction ที่กำหนดจากนั้นพยายามที่จะกระทำการเปลี่ยนแปลงที่ใช้ภายในธุรกรรม หากเอกสารใด ๆ ที่อ่านภายในการทำธุรกรรมมีการเปลี่ยนแปลง Cloud Firestore จะให้ updateFunction . หากล้มเหลวในการกระทำหลังจาก 5 ครั้งการทำธุรกรรมจะล้มเหลว

จำนวนการเขียนสูงสุดที่อนุญาตในการทำธุรกรรมเดียวคือ 500

ลายเซ็น:

export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง การอ้างอิงถึงฐานข้อมูล Firestore เพื่อเรียกใช้การทำธุรกรรมนี้
UpdateFunction (ธุรกรรม: ธุรกรรม ) => สัญญา <t> ฟังก์ชั่นเพื่อดำเนินการภายในบริบทการทำธุรกรรม
ตัวเลือก TransactionOptions ตัวเลือกวัตถุเพื่อกำหนดค่าจำนวนสูงสุดของความพยายามในการกระทำ

ผลตอบแทน:

สัญญา <t>

หากธุรกรรมเสร็จสมบูรณ์สำเร็จหรือถูกยกเลิกอย่างชัดเจน ( updateFunction ส่งคืนสัญญาที่ล้มเหลว) สัญญาที่ส่งคืนโดย updateFunction จะถูกส่งคืนที่นี่ มิฉะนั้นหากการทำธุรกรรมล้มเหลวสัญญาที่ถูกปฏิเสธด้วยข้อผิดพลาดความล้มเหลวที่สอดคล้องกันจะถูกส่งคืน

SetIndExConfiguration (Firestore, การกำหนดค่า)

API นี้มีให้เป็นตัวอย่างสำหรับนักพัฒนาและอาจเปลี่ยนแปลงตามข้อเสนอแนะที่เราได้รับ อย่าใช้ API นี้ในสภาพแวดล้อมการผลิต

แทนที่จะสร้างดัชนีแคชด้วยตนเองให้พิจารณาใช้ enablePersistentCacheIndexAutoCreation() เพื่อให้ SDK ตัดสินใจว่าจะสร้างดัชนีแคชสำหรับการสืบค้นที่ทำงานในเครื่องหรือไม่

กำหนดค่าการจัดทำดัชนีสำหรับการดำเนินการแบบสอบถามในท้องถิ่น การกำหนดค่าดัชนีก่อนหน้านี้จะถูกแทนที่ Promise จะแก้ไขได้เมื่อการกำหนดค่าดัชนียังคงมีอยู่

รายการดัชนีเองถูกสร้างขึ้นแบบอะซิงโครนัส คุณสามารถใช้การสืบค้นที่ต้องการการจัดทำดัชนีต่อไปแม้ว่าจะยังไม่สามารถใช้ดัชนีได้ก็ตาม การดำเนินการแบบสอบถามจะเริ่มใช้ดัชนีโดยอัตโนมัติเมื่อมีการเขียนรายการดัชนีแล้ว

ดัชนีได้รับการสนับสนุนเฉพาะการคงอยู่ของดัชนี DB หากไม่ได้เปิดใช้งาน indexedDB การกำหนดค่าดัชนีใด ๆ จะถูกละเว้น

ลายเซ็น:

export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อกำหนดค่าดัชนีสำหรับ
การกำหนดค่า การกำหนดค่าดัชนี คำจำกัดความของดัชนี

ผลตอบแทน:

สัญญา <Void>

Promise ที่แก้ไขได้เมื่อมีการกำหนดค่าดัชนีทั้งหมดสำเร็จ

ข้อยกเว้น

firestoreerror หากรูปแบบ JSON ไม่ถูกต้อง

SetIndExConfiguration (Firestore, JSON)

API นี้มีให้เป็นตัวอย่างสำหรับนักพัฒนาและอาจเปลี่ยนแปลงตามข้อเสนอแนะที่เราได้รับ อย่าใช้ API นี้ในสภาพแวดล้อมการผลิต

แทนที่จะสร้างดัชนีแคชด้วยตนเองให้พิจารณาใช้ enablePersistentCacheIndexAutoCreation() เพื่อให้ SDK ตัดสินใจว่าจะสร้างดัชนีแคชสำหรับการสืบค้นที่ทำงานในเครื่องหรือไม่

กำหนดค่าการจัดทำดัชนีสำหรับการดำเนินการแบบสอบถามในท้องถิ่น การกำหนดค่าดัชนีก่อนหน้านี้จะถูกแทนที่ Promise จะแก้ไขได้เมื่อการกำหนดค่าดัชนียังคงมีอยู่

รายการดัชนีเองถูกสร้างขึ้นแบบอะซิงโครนัส คุณสามารถใช้การสืบค้นที่ต้องการการจัดทำดัชนีต่อไปแม้ว่าจะยังไม่สามารถใช้ดัชนีได้ก็ตาม การดำเนินการแบบสอบถามจะเริ่มใช้ดัชนีโดยอัตโนมัติเมื่อมีการเขียนรายการดัชนีแล้ว

ดัชนีได้รับการสนับสนุนเฉพาะการคงอยู่ของดัชนี DB เรียกใช้ enableIndexedDbPersistence() หรือ enableMultiTabIndexedDbPersistence() ก่อนตั้งค่าการกำหนดค่าดัชนี หากไม่ได้เปิดใช้งาน indexedDB การกำหนดค่าดัชนีใด ๆ จะถูกละเว้น

วิธีการยอมรับรูปแบบ JSON ที่ส่งออกโดย Firebase CLI ( firebase firestore:indexes ). หากรูปแบบ JSON ไม่ถูกต้องวิธีนี้จะเกิดข้อผิดพลาด

ลายเซ็น:

export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง อินสแตนซ์ Firestore เพื่อกำหนดค่าดัชนีสำหรับ
json.json เชือก รูปแบบ JSON ที่ส่งออกโดย Firebase CLI

ผลตอบแทน:

สัญญา <Void>

Promise ที่แก้ไขได้เมื่อมีการกำหนดค่าดัชนีทั้งหมดสำเร็จ

ข้อยกเว้น

firestoreerror หากรูปแบบ JSON ไม่ถูกต้อง

ยุติ (Firestore)

ยุติอินสแตนซ์ Firestore ที่ให้ไว้

หลังจากการโทร terminate() เฉพาะฟังก์ชัน clearIndexedDbPersistence() เท่านั้น ฟังก์ชั่นอื่น ๆ จะโยน FirestoreError .

หากต้องการเริ่มต้นใหม่หลังจากการเลิกจ้างให้สร้างอินสแตนซ์ใหม่ของ FirebaseFirestore ด้วย getFirestore () .

การเลิกจ้างไม่ได้ยกเลิกการเขียนที่ค้างอยู่และสัญญาใด ๆ ที่กำลังรอการตอบกลับจากเซิร์ฟเวอร์จะไม่ได้รับการแก้ไข หากคุณเปิดใช้งานการคงอยู่ในครั้งต่อไปที่คุณเริ่มอินสแตนซ์นี้จะกลับมาส่งการเขียนเหล่านี้ไปยังเซิร์ฟเวอร์

ลายเซ็น:

export declare function terminate(firestore: Firestore): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง

ผลตอบแทน:

สัญญา <Void>

Promise ที่ได้รับการแก้ไขเมื่ออินสแตนซ์ถูกยกเลิกสำเร็จ

WaitForPendingWrites (Firestore)

รอจนกว่าจะมีการเขียนทั้งหมดที่รอการเขียนสำหรับผู้ใช้ที่ใช้งานอยู่ได้รับการยอมรับจากแบ็กเอนด์

สัญญาที่ส่งคืนจะแก้ไขได้ทันทีหากไม่มีการเขียนที่โดดเด่น มิฉะนั้นสัญญาจะรอคำเขียนที่ออกก่อนหน้านี้ทั้งหมด (รวมถึงที่เขียนในเซสชันแอพก่อนหน้า) แต่มันไม่รอการเขียนที่เพิ่มขึ้นหลังจากเรียกใช้ฟังก์ชั่น หากคุณต้องการรอการเขียนเพิ่มเติมให้โทรหา waitForPendingWrites() อีกครั้ง

คำสัญญาใด ๆ ที่โดดเด่น waitForPendingWrites() จะถูกปฏิเสธระหว่างการเปลี่ยนแปลงของผู้ใช้

ลายเซ็น:

export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง

ผลตอบแทน:

สัญญา <Void>

Promise ที่แก้ไขเมื่อการเขียนที่ค้างอยู่ในปัจจุบันได้รับการยอมรับจากแบ็กเอนด์

Writebatch (Firestore)

สร้างแบทช์เขียนที่ใช้สำหรับการเขียนหลายครั้งเป็นการดำเนินการอะตอมเดียว จำนวนการเขียนสูงสุดที่อนุญาตใน writebatch เดียวคือ 500

ซึ่งแตกต่างจากการทำธุรกรรมการเขียนแบทช์จะคงอยู่แบบออฟไลน์ดังนั้นจึงเป็นที่นิยมเมื่อคุณไม่จำเป็นต้องกำหนดเงื่อนไขการเขียนของคุณเกี่ยวกับข้อมูลการอ่าน

ลายเซ็น:

export declare function writeBatch(firestore: Firestore): WriteBatch;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
เปลวไฟ ร้านดับเพลิง

ผลตอบแทน:

batch

batch batch ที่สามารถใช้ในการดำเนินการเขียนหลายครั้ง

การทำงาน()

นับ()

สร้างวัตถุรวมฟีลล์ที่สามารถใช้ในการคำนวณจำนวนเอกสารในชุดผลลัพธ์ของแบบสอบถาม

ลายเซ็น:

export declare function count(): AggregateField<number>;

ผลตอบแทน:

ฟีลล์รวม <จำนวน>

DELETEFIELD ()

ส่งคืน Sentinel เพื่อใช้กับ updateDoC () หรือ setDoc () ด้วย {merge: true} เพื่อทำเครื่องหมายฟิลด์สำหรับการลบ

ลายเซ็น:

export declare function deleteField(): FieldValue;

ผลตอบแทน:

ค่าเงิน

DocumentId ()

ส่งคืน Sentinel FieldPath พิเศษเพื่ออ้างถึง ID ของเอกสาร สามารถใช้ในการสืบค้นเพื่อเรียงลำดับหรือกรองด้วยรหัสเอกสาร

ลายเซ็น:

export declare function documentId(): FieldPath;

ผลตอบแทน:

สนามบิน

getFirestore ()

ส่งคืนอินสแตนซ์ Firestore เริ่มต้นที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp เริ่มต้น . หากไม่มีอินสแตนซ์ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น

ลายเซ็น:

export declare function getFirestore(): Firestore;

ผลตอบแทน:

ร้านดับเพลิง

อินสแตนซ์ Firestore เริ่มต้นของแอพเริ่มต้น

Memoryeagergarbagecollector ()

สร้างอินสแตนซ์ของ MemoryEagerGarbageCollector . นี่เป็นตัวสะสมขยะเริ่มต้นเว้นแต่จะมีการระบุอย่างชัดเจนเป็นอย่างอื่น

ลายเซ็น:

export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector;

ผลตอบแทน:

Memoryeagerbagecollector

PresententMultipleTabManager ()

สร้างอินสแตนซ์ของ PersistentMultipleTabManager .

ลายเซ็น:

export declare function persistentMultipleTabManager(): PersistentMultipleTabManager;

ผลตอบแทน:

PresententMultipleTabManager

servertimestamp ()

ส่งคืน Sentinel ที่ใช้กับ setDoc () หรือ updateDoC () เพื่อรวมการประทับเวลาที่สร้างจากเซิร์ฟเวอร์ในข้อมูลที่เป็นลายลักษณ์อักษร

ลายเซ็น:

export declare function serverTimestamp(): FieldValue;

ผลตอบแทน:

ค่าเงิน

ฟังก์ชั่น (databaseid, ... )

GetFirestore (DatabaseID)

API นี้มีให้เป็นตัวอย่างสำหรับนักพัฒนาและอาจเปลี่ยนแปลงตามข้อเสนอแนะที่เราได้รับ อย่าใช้ API นี้ในสภาพแวดล้อมการผลิต

ส่งคืนอินสแตนซ์ Firestore ชื่อที่มีอยู่ซึ่งเชื่อมโยงกับ FirebaseApp เริ่มต้น . หากไม่มีอินสแตนซ์ให้เริ่มต้นอินสแตนซ์ใหม่ด้วยการตั้งค่าเริ่มต้น

ลายเซ็น:

export declare function getFirestore(databaseId: string): Firestore;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ฐานข้อมูล เชือก ชื่อของฐานข้อมูล

ผลตอบแทน:

ร้านดับเพลิง

อินสแตนซ์ Firestore ชื่อของแอพเริ่มต้น

ฟังก์ชั่น (องค์ประกอบ, ... )

Arrayremove (องค์ประกอบ)

ส่งคืนค่าพิเศษที่สามารถใช้กับ setDoc () หรือที่บอกให้เซิร์ฟเวอร์ลบองค์ประกอบที่กำหนดออกจากค่าอาร์เรย์ใด ๆ ที่มีอยู่แล้วบนเซิร์ฟเวอร์ อินสแตนซ์ทั้งหมดของแต่ละองค์ประกอบที่ระบุจะถูกลบออกจากอาร์เรย์ If the field being modified is not already an array it will be overwritten with an empty array.

ลายเซ็น:

export declare function arrayRemove(...elements: unknown[]): FieldValue;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
องค์ประกอบ unknown[] The elements to remove from the array.

ผลตอบแทน:

FieldValue

The FieldValue sentinel for use in a call to setDoc() or updateDoc()

arrayUnion(elements)

Returns a special value that can be used with setDoc() or updateDoc() that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements.

ลายเซ็น:

export declare function arrayUnion(...elements: unknown[]): FieldValue;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
องค์ประกอบ unknown[] The elements to union into the array.

ผลตอบแทน:

FieldValue

The FieldValue sentinel for use in a call to setDoc() or updateDoc() .

function(field, ...)

average(field)

Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

ลายเซ็น:

export declare function average(field: string | FieldPath): AggregateField<number | null>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
สนาม string | FieldPath Specifies the field to average across the result set.

ผลตอบแทน:

AggregateField <number | null>

sum(field)

Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

ลายเซ็น:

export declare function sum(field: string | FieldPath): AggregateField<number>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
สนาม string | FieldPath Specifies the field to sum across the result set.

ผลตอบแทน:

AggregateField <จำนวน>

function(fieldPath, ...)

orderBy(fieldPath, directionStr)

Creates a QueryOrderByConstraint that sorts the query result by the specified field, optionally in descending order instead of ascending.

ลายเซ็น:

export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
fieldPath string | FieldPath The field to sort by.
directionStr OrderByDirection Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending.

ผลตอบแทน:

QueryOrderByConstraint

The created QueryOrderByConstraint .

where(fieldPath, opStr, value)

Creates a QueryFieldFilterConstraint that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided.

ลายเซ็น:

export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
fieldPath string | FieldPath The path to compare
opStr WhereFilterOp The operation string (eg "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!=").
ค่า ไม่ทราบ The value for comparison

ผลตอบแทน:

QueryFieldFilterConstraint

The created QueryFieldFilterConstraint .

function(fieldValues, ...)

endAt(fieldValues)

Creates a QueryEndAtConstraint that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

ลายเซ็น:

export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
fieldValues unknown[] The field values to end this query at, in order of the query's order by.

ผลตอบแทน:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

endBefore(fieldValues)

Creates a QueryEndAtConstraint that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

ลายเซ็น:

export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
fieldValues unknown[] The field values to end this query before, in order of the query's order by.

ผลตอบแทน:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

startAfter(fieldValues)

Creates a QueryStartAtConstraint that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

ลายเซ็น:

export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
fieldValues unknown[] The field values to start this query after, in order of the query's order by.

ผลตอบแทน:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query()

startAt(fieldValues)

Creates a QueryStartAtConstraint that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

ลายเซ็น:

export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
fieldValues unknown[] The field values to start this query at, in order of the query's order by.

ผลตอบแทน:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query() .

function(indexManager, ...)

deleteAllPersistentCacheIndexes(indexManager)

Removes all persistent cache indexes.

Please note this function will also deletes indexes generated by setIndexConfiguration() , which is deprecated.

ลายเซ็น:

export declare function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
indexManager PersistentCacheIndexManager

ผลตอบแทน:

เป็นโมฆะ

disablePersistentCacheIndexAutoCreation(indexManager)

Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect.

ลายเซ็น:

export declare function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
indexManager PersistentCacheIndexManager

ผลตอบแทน:

เป็นโมฆะ

enablePersistentCacheIndexAutoCreation(indexManager)

Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.

This feature is disabled by default.

ลายเซ็น:

export declare function enablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
indexManager PersistentCacheIndexManager

ผลตอบแทน:

เป็นโมฆะ

function(left, ...)

aggregateFieldEqual(left, right)

Compares two 'AggregateField ` instances for equality.

ลายเซ็น:

export declare function aggregateFieldEqual(left: AggregateField<unknown>, right: AggregateField<unknown>): boolean;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ซ้าย AggregateField <unknown> Compare this AggregateField to the right .
ขวา AggregateField <unknown> Compare this AggregateField to the left .

ผลตอบแทน:

บูลีน

aggregateQuerySnapshotEqual(left, right)

Compares two AggregateQuerySnapshot instances for equality.

Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data.

ลายเซ็น:

export declare function aggregateQuerySnapshotEqual<AggregateSpecType extends AggregateSpec, AppModelType, DbModelType extends DocumentData>(left: AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>, right: AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>): boolean;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ซ้าย AggregateQuerySnapshot <AggregateSpecType, AppModelType, DbModelType> The first AggregateQuerySnapshot to compare.
ขวา AggregateQuerySnapshot <AggregateSpecType, AppModelType, DbModelType> The second AggregateQuerySnapshot to compare.

ผลตอบแทน:

บูลีน

true if the objects are "equal", as defined above, or false otherwise.

queryEqual(left, right)

Returns true if the provided queries point to the same collection and apply the same constraints.

ลายเซ็น:

export declare function queryEqual<AppModelType, DbModelType extends DocumentData>(left: Query<AppModelType, DbModelType>, right: Query<AppModelType, DbModelType>): boolean;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ซ้าย แบบสอบถาม <AppModelType, DbModelType> A Query to compare.
ขวา แบบสอบถาม <AppModelType, DbModelType> A Query to compare.

ผลตอบแทน:

บูลีน

true if the references point to the same location in the same Firestore database.

refEqual(left, right)

Returns true if the provided references are equal.

ลายเซ็น:

export declare function refEqual<AppModelType, DbModelType extends DocumentData>(left: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>, right: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>): boolean;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ซ้าย DocumentReference <AppModelType, DbModelType> | CollectionReference <AppModelType, DbModelType> A reference to compare.
ขวา DocumentReference <AppModelType, DbModelType> | CollectionReference <AppModelType, DbModelType> A reference to compare.

ผลตอบแทน:

บูลีน

true if the references point to the same location in the same Firestore database.

snapshotEqual(left, right)

Returns true if the provided snapshots are equal.

ลายเซ็น:

export declare function snapshotEqual<AppModelType, DbModelType extends DocumentData>(left: DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType>, right: DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType>): boolean;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ซ้าย DocumentSnapshot <AppModelType, DbModelType> | QuerySnapshot <AppModelType, DbModelType> A snapshot to compare.
ขวา DocumentSnapshot <AppModelType, DbModelType> | QuerySnapshot <AppModelType, DbModelType> A snapshot to compare.

ผลตอบแทน:

บูลีน

true if the snapshots are equal.

function(limit, ...)

limit(limit)

Creates a QueryLimitConstraint that only returns the first matching documents.

ลายเซ็น:

export declare function limit(limit: number): QueryLimitConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ขีด จำกัด ตัวเลข The maximum number of items to return.

ผลตอบแทน:

QueryLimitConstraint

The created QueryLimitConstraint .

limitToLast(limit)

Creates a QueryLimitConstraint that only returns the last matching documents.

You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution.

ลายเซ็น:

export declare function limitToLast(limit: number): QueryLimitConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
ขีด จำกัด ตัวเลข The maximum number of items to return.

ผลตอบแทน:

QueryLimitConstraint

The created QueryLimitConstraint .

function(logLevel, ...)

setLogLevel(logLevel)

Sets the verbosity of Cloud Firestore logs (debug, error, or silent).

ลายเซ็น:

export declare function setLogLevel(logLevel: LogLevel): void;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
logLevel ระดับบันทึก The verbosity you set for activity and error logging. Can be any of the following values:
  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.

ผลตอบแทน:

เป็นโมฆะ

function(n, ...)

increment(n)

Returns a special value that can be used with setDoc() or updateDoc() that tells the server to increment the field's current value by the given value.

If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range ( Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER ) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.

If the current field value is not of type number , or if the field does not yet exist, the transformation sets the field to the given value.

ลายเซ็น:

export declare function increment(n: number): FieldValue;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
n ตัวเลข The value to increment by.

ผลตอบแทน:

FieldValue

The FieldValue sentinel for use in a call to setDoc() or updateDoc()

function(query, ...)

getAggregateFromServer(query, aggregateSpec)

Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.

Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).

The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server.

ลายเซ็น:

export declare function getAggregateFromServer<AggregateSpecType extends AggregateSpec, AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, aggregateSpec: AggregateSpecType): Promise<AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The query whose result set is aggregated over.
aggregateSpec AggregateSpecType An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result.

ผลตอบแทน:

Promise< AggregateQuerySnapshot <AggregateSpecType, AppModelType, DbModelType>>

ตัวอย่าง

const aggregateSnapshot = await getAggregateFromServer(query, {
  countOfDocs: count(),
  totalHours: sum('hours'),
  averageScore: average('score')
});

const countOfDocs: number = aggregateSnapshot.data().countOfDocs;
const totalHours: number = aggregateSnapshot.data().totalHours;
const averageScore: number | null = aggregateSnapshot.data().averageScore;

getCountFromServer(query)

Calculates the number of documents in the result set of the given query without actually downloading the documents.

Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).

The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server.

ลายเซ็น:

export declare function getCountFromServer<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<AggregateQuerySnapshot<{
    count: AggregateField<number>;
}, AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The query whose result set size is calculated.

ผลตอบแทน:

Promise< AggregateQuerySnapshot <{ count: AggregateField <number>; }, AppModelType, DbModelType>>

A Promise that will be resolved with the count; the count can be retrieved from snapshot.data().count , where snapshot is the AggregateQuerySnapshot to which the returned Promise resolves.

getDocs(query)

Executes the query and returns the results as a QuerySnapshot .

ลายเซ็น:

export declare function getDocs<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<QuerySnapshot<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType>

ผลตอบแทน:

Promise< QuerySnapshot <AppModelType, DbModelType>>

A Promise that will be resolved with the results of the query.

getDocsFromCache(query)

Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached.

ลายเซ็น:

export declare function getDocsFromCache<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<QuerySnapshot<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType>

ผลตอบแทน:

Promise< QuerySnapshot <AppModelType, DbModelType>>

A Promise that will be resolved with the results of the query.

getDocsFromServer(query)

Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available.

ลายเซ็น:

export declare function getDocsFromServer<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<QuerySnapshot<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType>

ผลตอบแทน:

Promise< QuerySnapshot <AppModelType, DbModelType>>

A Promise that will be resolved with the results of the query.

onSnapshot(query, observer)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, observer: {
    next?: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The query to listen to.
ผู้สังเกตการณ์ { next?: (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(query, options, observer)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, observer: {
    next?: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The query to listen to.
ตัวเลือก SnapshotListenOptions Options controlling the listen behavior.
ผู้สังเกตการณ์ { next?: (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(query, onNext, onError, onCompletion)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The query to listen to.
onNext (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new QuerySnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
เมื่อเสร็จสิ้น () => void Can be provided, but will not be called since streams are never ending.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(query, options, onNext, onError, onCompletion)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The query to listen to.
ตัวเลือก SnapshotListenOptions Options controlling the listen behavior.
onNext (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new QuerySnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
เมื่อเสร็จสิ้น () => void Can be provided, but will not be called since streams are never ending.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

query(query, compositeFilter, queryConstraints)

Creates a new immutable instance of Query that is extended to also include additional query constraints.

ลายเซ็น:

export declare function query<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query<AppModelType, DbModelType>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The Query instance to use as a base for the new constraints.
compositeFilter QueryCompositeFilterConstraint The QueryCompositeFilterConstraint to apply. Create QueryCompositeFilterConstraint using and() or or() .
queryConstraints QueryNonFilterConstraint [] Additional QueryNonFilterConstraint s to apply (eg orderBy() , limit() ).

ผลตอบแทน:

แบบสอบถาม <AppModelType, DbModelType>

ข้อยกเว้น

if any of the provided query constraints cannot be combined with the existing or new constraints.

query(query, queryConstraints)

Creates a new immutable instance of Query that is extended to also include additional query constraints.

ลายเซ็น:

export declare function query<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, ...queryConstraints: QueryConstraint[]): Query<AppModelType, DbModelType>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
แบบสอบถาม แบบสอบถาม <AppModelType, DbModelType> The Query instance to use as a base for the new constraints.
queryConstraints QueryConstraint [] The list of QueryConstraint s to apply.

ผลตอบแทน:

แบบสอบถาม <AppModelType, DbModelType>

ข้อยกเว้น

if any of the provided query constraints cannot be combined with the existing or new constraints.

function(queryConstraints, ...)

and(queryConstraints)

Creates a new QueryCompositeFilterConstraint that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters.

ลายเซ็น:

export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
queryConstraints QueryFilterConstraint [] ไม่จำเป็น. The list of QueryFilterConstraint s to perform a conjunction for. These must be created with calls to where() , หรือ() , or and() .

ผลตอบแทน:

QueryCompositeFilterConstraint

The newly created QueryCompositeFilterConstraint .

or(queryConstraints)

Creates a new QueryCompositeFilterConstraint that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters.

ลายเซ็น:

export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
queryConstraints QueryFilterConstraint [] ไม่จำเป็น. The list of QueryFilterConstraint s to perform a disjunction for. These must be created with calls to where() , หรือ() , or and() .

ผลตอบแทน:

QueryCompositeFilterConstraint

The newly created QueryCompositeFilterConstraint .

function(reference, ...)

addDoc(reference, data)

Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically.

ลายเซ็น:

export declare function addDoc<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<DocumentReference<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง CollectionReference <AppModelType, DbModelType> A reference to the collection to add this document to.
ข้อมูล WithFieldValue <AppModelType> An Object containing the data for the new document.

ผลตอบแทน:

Promise< DocumentReference <AppModelType, DbModelType>>

A Promise resolved with a DocumentReference pointing to the newly created document after it has been written to the backend (Note that it won't resolve while you're offline).

collection(reference, path, pathSegments)

Gets a CollectionReference instance that refers to a subcollection of reference at the the specified relative path.

ลายเซ็น:

export declare function collection<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData, DocumentData>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง CollectionReference <AppModelType, DbModelType> A reference to a collection.
เส้นทาง เชือก A slash-separated path to a collection.
pathSegments string[] Additional path segments to apply relative to the first argument.

ผลตอบแทน:

CollectionReference < DocumentData , DocumentData >

The CollectionReference instance.

ข้อยกเว้น

If the final path has an even number of segments and does not point to a collection.

collection(reference, path, pathSegments)

Gets a CollectionReference instance that refers to a subcollection of reference at the the specified relative path.

ลายเซ็น:

export declare function collection<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData, DocumentData>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to a Firestore document.
เส้นทาง เชือก A slash-separated path to a collection.
pathSegments string[] Additional path segments that will be applied relative to the first argument.

ผลตอบแทน:

CollectionReference < DocumentData , DocumentData >

The CollectionReference instance.

ข้อยกเว้น

If the final path has an even number of segments and does not point to a collection.

deleteDoc(reference)

Deletes the document referred to by the specified DocumentReference .

ลายเซ็น:

export declare function deleteDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to delete.

ผลตอบแทน:

Promise<void>

A Promise resolved once the document has been successfully deleted from the backend (note that it won't resolve while you're offline).

doc(reference, path, pathSegments)

Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference .

ลายเซ็น:

export declare function doc<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, path?: string, ...pathSegments: string[]): DocumentReference<AppModelType, DbModelType>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง CollectionReference <AppModelType, DbModelType> A reference to a collection.
เส้นทาง เชือก A slash-separated path to a document. Has to be omitted to use auto-genrated IDs.
pathSegments string[] Additional path segments that will be applied relative to the first argument.

ผลตอบแทน:

DocumentReference <AppModelType, DbModelType>

The DocumentReference instance.

ข้อยกเว้น

If the final path has an odd number of segments and does not point to a document.

doc(reference, path, pathSegments)

Gets a DocumentReference instance that refers to a document within reference at the specified relative path.

ลายเซ็น:

export declare function doc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData, DocumentData>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to a Firestore document.
เส้นทาง เชือก A slash-separated path to a document.
pathSegments string[] Additional path segments that will be applied relative to the first argument.

ผลตอบแทน:

DocumentReference < DocumentData , DocumentData >

The DocumentReference instance.

ข้อยกเว้น

If the final path has an odd number of segments and does not point to a document.

getDoc(reference)

Reads the document referred to by this DocumentReference .

ลายเซ็น:

export declare function getDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> The reference of the document to fetch.

ผลตอบแทน:

Promise< DocumentSnapshot <AppModelType, DbModelType>>

A Promise resolved with a DocumentSnapshot containing the current document contents.

getDocFromCache(reference)

Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached.

ลายเซ็น:

export declare function getDocFromCache<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType>

ผลตอบแทน:

Promise< DocumentSnapshot <AppModelType, DbModelType>>

A Promise resolved with a DocumentSnapshot containing the current document contents.

getDocFromServer(reference)

Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available.

ลายเซ็น:

export declare function getDocFromServer<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType>

ผลตอบแทน:

Promise< DocumentSnapshot <AppModelType, DbModelType>>

A Promise resolved with a DocumentSnapshot containing the current document contents.

onSnapshot(reference, observer)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, observer: {
    next?: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
ผู้สังเกตการณ์ { next?: (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(reference, options, observer)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, options: SnapshotListenOptions, observer: {
    next?: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
ตัวเลือก SnapshotListenOptions Options controlling the listen behavior.
ผู้สังเกตการณ์ { next?: (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(reference, onNext, onError, onCompletion)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
onNext (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new DocumentSnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
เมื่อเสร็จสิ้น () => void Can be provided, but will not be called since streams are never ending.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(reference, options, onNext, onError, onCompletion)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

ลายเซ็น:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
ตัวเลือก SnapshotListenOptions Options controlling the listen behavior.
onNext (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new DocumentSnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
เมื่อเสร็จสิ้น () => void Can be provided, but will not be called since streams are never ending.

ผลตอบแทน:

ยกเลิกการสมัคร

An unsubscribe function that can be called to cancel the snapshot listener.

setDoc(reference, data)

Writes to the document referred to by this DocumentReference . If the document does not yet exist, it will be created.

ลายเซ็น:

export declare function setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to write.
ข้อมูล WithFieldValue <AppModelType> A map of the fields and values for the document.

ผลตอบแทน:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

setDoc(reference, data, options)

Writes to the document referred to by the specified DocumentReference . If the document does not yet exist, it will be created. If you provide merge or mergeFields , the provided data can be merged into an existing document.

ลายเซ็น:

export declare function setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: PartialWithFieldValue<AppModelType>, options: SetOptions): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to write.
ข้อมูล PartialWithFieldValue <AppModelType> A map of the fields and values for the document.
ตัวเลือก SetOptions An object to configure the set behavior.

ผลตอบแทน:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

updateDoc(reference, data)

Updates fields in the document referred to by the specified DocumentReference . The update will fail if applied to a document that does not exist.

ลายเซ็น:

export declare function updateDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: UpdateData<DbModelType>): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to update.
ข้อมูล UpdateData <DbModelType> An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document.

ผลตอบแทน:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

updateDoc(reference, field, value, moreFieldsAndValues)

Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.

Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects.

ลายเซ็น:

export declare function updateDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise<void>;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
อ้างอิง DocumentReference <AppModelType, DbModelType> A reference to the document to update.
สนาม string | FieldPath The first field to update.
ค่า ไม่ทราบ The first value.
moreFieldsAndValues unknown[] Additional key value pairs.

ผลตอบแทน:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

function(settings, ...)

memoryLocalCache(settings)

Creates an instance of MemoryLocalCache . The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.

ลายเซ็น:

export declare function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
การตั้งค่า MemoryCacheSettings

ผลตอบแทน:

MemoryLocalCache

memoryLruGarbageCollector(settings)

Creates an instance of MemoryLruGarbageCollector .

A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 * 1024 * 1024 bytes).

ลายเซ็น:

export declare function memoryLruGarbageCollector(settings?: {
    cacheSizeBytes?: number;
}): MemoryLruGarbageCollector;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
การตั้งค่า { cacheSizeBytes?: number; }

ผลตอบแทน:

MemoryLruGarbageCollector

persistentLocalCache(settings)

Creates an instance of PersistentLocalCache . The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.

Persistent cache cannot be used in a Node.js environment.

ลายเซ็น:

export declare function persistentLocalCache(settings?: PersistentCacheSettings): PersistentLocalCache;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
การตั้งค่า PersistentCacheSettings

ผลตอบแทน:

PersistentLocalCache

persistentSingleTabManager(settings)

Creates an instance of PersistentSingleTabManager .

ลายเซ็น:

export declare function persistentSingleTabManager(settings: PersistentSingleTabManagerSettings | undefined): PersistentSingleTabManager;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
การตั้งค่า PersistentSingleTabManagerSettings | ไม่ได้กำหนด Configures the created tab manager.

ผลตอบแทน:

PersistentSingleTabManager

function(snapshot, ...)

endAt(snapshot)

Creates a QueryEndAtConstraint that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

ลายเซ็น:

export declare function endAt<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryEndAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
สแนปชอต DocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to end at.

ผลตอบแทน:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

endBefore(snapshot)

Creates a QueryEndAtConstraint that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

ลายเซ็น:

export declare function endBefore<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryEndAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
สแนปชอต DocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to end before.

ผลตอบแทน:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

startAfter(snapshot)

Creates a QueryStartAtConstraint that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

ลายเซ็น:

export declare function startAfter<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryStartAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
สแนปชอต DocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to start after.

ผลตอบแทน:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query()

startAt(snapshot)

Creates a QueryStartAtConstraint that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

ลายเซ็น:

export declare function startAt<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryStartAtConstraint;

พารามิเตอร์

พารามิเตอร์ พิมพ์ คำอธิบาย
สแนปชอต DocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to start at.

ผลตอบแทน:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query() .

CACHE_SIZE_UNLIMITED

Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the Firestore instance.

ลายเซ็น:

CACHE_SIZE_UNLIMITED = -1

AddPrefixToKeys

Returns a new map where every key is prefixed with the outer key appended to a dot.

ลายเซ็น:

export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
    [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K];
};

AggregateFieldType

The union of all AggregateField types that are supported by Firestore.

ลายเซ็น:

export declare type AggregateFieldType = ReturnType<typeof sum> | ReturnType<typeof average> | ReturnType<typeof count>;

AggregateSpecData

A type whose keys are taken from an AggregateSpec , and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec .

ลายเซ็น:

export declare type AggregateSpecData<T extends AggregateSpec> = {
    [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
};

AggregateType

Union type representing the aggregate type to be performed.

ลายเซ็น:

export declare type AggregateType = 'count' | 'avg' | 'sum';

ChildUpdateFields

Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B} .

In this use case, V is used to distribute the union types of T[K] on Record , since T[K] is evaluated as an expression and not distributed.

See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types

ลายเซ็น:

export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;

DocumentChangeType

The type of a DocumentChange may be 'added', 'removed', or 'modified'.

ลายเซ็น:

export declare type DocumentChangeType = 'added' | 'removed' | 'modified';

FirestoreErrorCode

The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md

Possible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (eg an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation.

ลายเซ็น:

export declare type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';

FirestoreLocalCache

Union type from all supported SDK cache layer.

ลายเซ็น:

export declare type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache;

ListenSource

Describe the source a query listens to.

Set to default to listen to both cache and server changes. Set to cache to listen to changes in cache only.

ลายเซ็น:

export declare type ListenSource = 'default' | 'cache';

MemoryGarbageCollector

Union type from all support gabage collectors for memory local cache.

ลายเซ็น:

export declare type MemoryGarbageCollector = MemoryEagerGarbageCollector | MemoryLruGarbageCollector;

NestedUpdateFields

For each field (eg 'bar'), find all nested keys (eg { 'bar.baz': T1, 'bar.qux': T2 } ). Intersect them together to make a single map containing all possible keys that are all marked as optional

ลายเซ็น:

export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
    [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
}[keyof T & string]>;

OrderByDirection

The direction of a orderBy() clause is specified as 'desc' or 'asc' (descending or ascending).

ลายเซ็น:

export declare type OrderByDirection = 'desc' | 'asc';

PartialWithFieldValue

Similar to Typescript's Partial<T> , but allows nested fields to be omitted and FieldValues to be passed in as property values.

ลายเซ็น:

export declare type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? {
    [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue;
} : never);

PersistentTabManager

A union of all available tab managers.

ลายเซ็น:

export declare type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager;

ดั้งเดิม

Primitive types.

ลายเซ็น:

export declare type Primitive = string | number | boolean | undefined | null;

QueryConstraintType

Describes the different query constraints available in this SDK.

ลายเซ็น:

export declare type QueryConstraintType = 'where' | 'orderBy' | 'limit' | 'limitToLast' | 'startAt' | 'startAfter' | 'endAt' | 'endBefore';

QueryFilterConstraint

QueryFilterConstraint is a helper union type that represents QueryFieldFilterConstraint and QueryCompositeFilterConstraint .

ลายเซ็น:

export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCompositeFilterConstraint;

QueryNonFilterConstraint

QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraint s are created by invoking orderBy() , เริ่มต้นที่() , startAfter() , endBefore() , endAt() , limit() or limitToLast() and can then be passed to query() to create a new query instance that also contains the QueryConstraint .

ลายเซ็น:

export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;

SetOptions

An options object that configures the behavior of setDoc() , and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true .

ลายเซ็น:

export declare type SetOptions = {
    readonly merge?: boolean;
} | {
    readonly mergeFields?: Array<string | FieldPath>;
};

TaskState

Represents the state of bundle loading tasks.

Both 'Error' and 'Success' are sinking state: task will abort or complete and there will be no more updates after they are reported.

ลายเซ็น:

export declare type TaskState = 'Error' | 'Running' | 'Success';

UnionToIntersection

Given a union type U = T1 | T2 | ... , returns an intersected type (T1 & T2 & ...) .

Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection -พิมพ์

ลายเซ็น:

export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

UpdateData

Update data (for use with updateDoc() ) that consists of field paths (eg 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values.

ลายเซ็น:

export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
    [K in keyof T]?: UpdateData<T[K]> | FieldValue;
} & NestedUpdateFields<T> : Partial<T>;

WhereFilterOp

Filter conditions in a where() clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'.

ลายเซ็น:

export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';

WithFieldValue

Allows FieldValues to be passed in as a property value while maintaining type safety.

ลายเซ็น:

export declare type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? {
    [K in keyof T]: WithFieldValue<T[K]> | FieldValue;
} : never);