@firebase/firestore

المهام

وظيفة وصف
وظيفة (التطبيق، ...)
احصل على فايرستور (التطبيق) إرجاع مثيل Firestore الافتراضي الحالي المرتبط بـ FirebaseApp المقدم . في حالة عدم وجود مثيل، قم بتهيئة مثيل جديد بالإعدادات الافتراضية.
getFirestore (التطبيق، معرف قاعدة البيانات) (تجريبي) يُرجع مثيل Firestore المسمى الموجود والمقترن بـ FirebaseApp المقدم . في حالة عدم وجود مثيل، قم بتهيئة مثيل جديد بالإعدادات الافتراضية.
تهيئةFirestore (التطبيق، الإعدادات، معرف قاعدة البيانات) تهيئة مثيل جديد لـ Firestore بالإعدادات المتوفرة. لا يمكن استدعاؤه إلا قبل أي وظيفة أخرى، بما في ذلك getFirestore() . إذا كانت الإعدادات المخصصة فارغة، فإن هذه الوظيفة تعادل استدعاء getFirestore() .
وظيفة (فيرستور، ...)
ClearIndexedDbPersistence(firestore) يمسح التخزين المستمر. يتضمن ذلك عمليات الكتابة المعلقة والمستندات المخزنة مؤقتًا. يجب الاتصال به أثناء عدم بدء تشغيل مثيل Firestore (بعد إنهاء التطبيق أو عند تهيئة التطبيق لأول مرة). عند بدء التشغيل، يجب استدعاء هذه الوظيفة قبل الوظائف الأخرى (بخلاف تهيئةFirestore() أو getFirestore()) )). إذا كان مثيل Firestore لا يزال قيد التشغيل، فسيتم رفض الوعد برمز الخطأ الخاص failed-precondition . ملاحظة: يهدف clearIndexedDbPersistence() في المقام الأول إلى المساعدة في كتابة اختبارات موثوقة تستخدم Cloud Firestore. فهو يستخدم آلية فعالة لإسقاط البيانات الموجودة ولكنه لا يحاول الكتابة فوق البيانات المخزنة مؤقتًا بشكل آمن أو جعل البيانات المخزنة مؤقتًا غير قابلة للاسترداد. بالنسبة للتطبيقات الحساسة للكشف عن البيانات المخزنة مؤقتًا بين جلسات المستخدم، نوصي بشدة بعدم تمكين الثبات على الإطلاق.
المجموعة (firestore، path، pathSegments) يحصل على مثيل CollectionReference الذي يشير إلى المجموعة في المسار المطلق المحدد.
مجموعة المجموعة (متجر النار، معرف المجموعة) يقوم بإنشاء وإرجاع نسخة Query جديدة تتضمن كافة المستندات الموجودة في قاعدة البيانات والمضمنة في مجموعة أو مجموعة فرعية باستخدام collectionId المحدد.
ConnectFirestoreEmulator (firestore، host، port، options) قم بتعديل هذا المثيل للتواصل مع محاكي Cloud Firestore. ملاحظة: يجب استدعاء هذا قبل استخدام هذا المثيل لإجراء أية عمليات.
تعطيل الشبكة (متجر النار) تعطيل استخدام الشبكة لهذا المثيل. يمكن إعادة تمكينه عبر enableNetwork() . أثناء تعطيل الشبكة، فإن أي مستمع للقطات أو استدعاءات getDoc() أو getDocs() سترجع نتائج من ذاكرة التخزين المؤقت، وسيتم وضع أي عمليات كتابة في قائمة الانتظار حتى تتم استعادة الشبكة.
مستند (firestore، path، pathSegments) الحصول على مثيل DocumentReference الذي يشير إلى المستند الموجود في المسار المطلق المحدد.
تمكينIndexedDbPersistence (firestore، إعدادات الثبات) محاولات لتمكين التخزين المستمر، إن أمكن. في حالة الفشل، سيرفض enableIndexedDbPersistence() الوعد أو سيطرح استثناءً. هناك عدة أسباب وراء فشل ذلك، والتي يمكن تحديدها بواسطة code الموجود على الخطأ. * فشل الشرط المسبق: التطبيق مفتوح بالفعل في علامة تبويب متصفح أخرى. * غير مُنفذ: المتصفح غير متوافق مع تنفيذ الثبات دون اتصال. لاحظ أنه حتى بعد الفشل، سيظل مثيل Firestore قابلاً للاستخدام، ولكن سيتم تعطيل الاستمرارية في وضع عدم الاتصال. ملاحظة: يجب استدعاء enableIndexedDbPersistence() قبل أي وظائف أخرى (بخلاف تهيئةFirestore () أو getFirestore() أو ClearIndexedDbPersistence() . لا يمكن استخدام الثبات في بيئة Node.js.
تمكينMultiTabIndexedDbPersistence (firestore) محاولات لتمكين التخزين المستمر لعلامات التبويب المتعددة، إن أمكن. إذا تم تمكينه عبر جميع علامات التبويب، فإن جميع العمليات تشترك في الوصول إلى الثبات المحلي، بما في ذلك التنفيذ المشترك للاستعلامات وتحديثات المستندات المحلية التي يتم تعويض زمن الاستجابة عبر جميع المثيلات المتصلة. في حالة الفشل، سوف يرفض enableMultiTabIndexedDbPersistence() الوعد أو يطرح استثناءً. هناك عدة أسباب وراء فشل ذلك، والتي يمكن تحديدها بواسطة code الموجود على الخطأ. * فشل الشرط المسبق: التطبيق مفتوح بالفعل في علامة تبويب متصفح أخرى ولم يتم تمكين علامات التبويب المتعددة. * غير مُنفذ: المتصفح غير متوافق مع تنفيذ الثبات دون اتصال. لاحظ أنه حتى بعد الفشل، سيظل مثيل Firestore قابلاً للاستخدام، ولكن سيتم تعطيل الاستمرارية في وضع عدم الاتصال.
تمكين الشبكة (فيرستور) إعادة تمكين استخدام الشبكة لمثيل Firestore هذا بعد استدعاء سابق لـ disableNetwork() .
getPersistentCacheIndexManager(firestore) إرجاع مدير فهرس PersistentCache الذي يستخدمه كائن Firestore المحدد. مثيل PersistentCacheIndexManager ، أو null إذا لم يكن التخزين المحلي المستمر قيد الاستخدام.
تحميلBundle(firestore، BundleData) يقوم بتحميل حزمة Firestore في ذاكرة التخزين المؤقت المحلية.
nameQuery(firestore، الاسم) يقرأ استعلام Firestore من ذاكرة التخزين المؤقت المحلية، المحددة بالاسم المحدد. يتم تجميع الاستعلامات المسماة في حزم على جانب الخادم (مع المستندات الناتجة)، ويتم تحميلها إلى ذاكرة التخزين المؤقت المحلية باستخدام loadBundle . بمجرد الوصول إلى ذاكرة التخزين المؤقت المحلية، استخدم هذه الطريقة لاستخراج استعلام بالاسم.
onSnapshotsInSync(firestore، المراقب) إرفاق مستمع لحدث مزامنة اللقطات. يشير حدث اللقطات المتزامنة إلى أن جميع المستمعين المتأثرين بتغيير معين قد تم تشغيلهم، حتى لو كان التغيير الذي تم إنشاؤه بواسطة الخادم يؤثر على عدة مستمعين. ملاحظة: يشير حدث اللقطات المتزامنة فقط إلى أن المستمعين متزامنون مع بعضهم البعض، ولكنه لا يتعلق بما إذا كانت تلك اللقطات متزامنة مع الخادم أم لا. استخدم SnapshotMetadata في المستمعين الفرديين لتحديد ما إذا كانت اللقطة من ذاكرة التخزين المؤقت أو من الخادم.
onSnapshotsInSync(firestore، onSync) إرفاق مستمع لحدث مزامنة اللقطات. يشير حدث اللقطات المتزامنة إلى أن جميع المستمعين المتأثرين بتغيير معين قد تم تشغيلهم، حتى لو كان التغيير الذي تم إنشاؤه بواسطة الخادم يؤثر على عدة مستمعين. ملاحظة: يشير حدث اللقطات المتزامنة فقط إلى أن المستمعين متزامنون مع بعضهم البعض، ولكنه لا يتعلق بما إذا كانت تلك اللقطات متزامنة مع الخادم أم لا. استخدم SnapshotMetadata في المستمعين الفرديين لتحديد ما إذا كانت اللقطة من ذاكرة التخزين المؤقت أو من الخادم.
تشغيل المعاملات (firestore، updateFunction، options) ينفذ 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 (متجر النار) ينتظر حتى يتم الإقرار بجميع عمليات الكتابة المعلقة حاليًا للمستخدم النشط من خلال الواجهة الخلفية. يتم حل الوعد الذي تم إرجاعه على الفور في حالة عدم وجود عمليات كتابة معلقة. بخلاف ذلك، ينتظر الوعد جميع عمليات الكتابة التي تم إصدارها مسبقًا (بما في ذلك تلك المكتوبة في جلسة تطبيق سابقة)، لكنه لا ينتظر عمليات الكتابة التي تمت إضافتها بعد استدعاء الوظيفة. إذا كنت تريد انتظار عمليات الكتابة الإضافية، فاتصل بـ waitForPendingWrites() مرة أخرى. يتم رفض أي وعود waitForPendingWrites() أثناء تغييرات المستخدم.
WriteBatch (متجر النار) ينشئ دفعة كتابة، تُستخدم لتنفيذ عمليات كتابة متعددة كعملية ذرية واحدة. الحد الأقصى لعدد عمليات الكتابة المسموح بها في WriteBatch واحد هو 500. على عكس المعاملات، تستمر دفعات الكتابة في وضع عدم الاتصال، وبالتالي فهي مفضلة عندما لا تحتاج إلى اشتراط عمليات الكتابة على بيانات القراءة.
وظيفة()
عدد() قم بإنشاء كائن AggregateField الذي يمكن استخدامه لحساب عدد المستندات في مجموعة نتائج الاستعلام.
حذف الحقل () إرجاع حارس للاستخدام مع updateDoc() أو setDoc() مع {merge: true} لوضع علامة على الحقل للحذف.
معرف الوثيقة () تقوم بإرجاع FieldPath خاص للإشارة إلى معرف المستند. يمكن استخدامه في الاستعلامات للفرز أو التصفية حسب معرف المستند.
getFirestore() إرجاع مثيل Firestore الافتراضي الحالي المرتبط بـ FirebaseApp الافتراضي . في حالة عدم وجود مثيل، قم بتهيئة مثيل جديد بالإعدادات الافتراضية.
MemoryEagerGarbageCollector() إنشاء مثيل لـ MemoryEagerGarbageCollector . وهذا أيضًا هو مجمّع البيانات المهملة الافتراضي ما لم يتم تحديد خلاف ذلك بشكل صريح.
مستمرMultipleTabManager() إنشاء مثيل لـ PersistentMultipleTabManager .
الطابع الزمني للخادم () إرجاع الحارس المستخدم مع setDoc() أو updateDoc() لتضمين الطابع الزمني الذي أنشأه الخادم في البيانات المكتوبة.
الوظيفة (معرف قاعدة البيانات، ...)
getFirestore(معرف قاعدة البيانات) (تجريبي) يُرجع مثيل Firestore المسمى الموجود والمقترن بتطبيق FirebaseApp الافتراضي . في حالة عدم وجود مثيل، قم بتهيئة مثيل جديد بالإعدادات الافتراضية.
الوظيفة (العناصر، ...)
إزالة المصفوفة (العناصر) تُرجع قيمة خاصة يمكن استخدامها مع setDoc() أو تخبر الخادم بإزالة العناصر المحددة من أي قيمة مصفوفة موجودة بالفعل على الخادم. ستتم إزالة كافة مثيلات كل عنصر محدد من المصفوفة. إذا لم يكن الحقل الذي يتم تعديله مصفوفة بالفعل، فسيتم استبداله بمصفوفة فارغة.
المصفوفة (العناصر) تُرجع قيمة خاصة يمكن استخدامها مع setDoc() أو updateDoc() والتي تخبر الخادم بدمج العناصر المحددة مع أي قيمة مصفوفة موجودة بالفعل على الخادم. ستتم إضافة كل عنصر محدد غير موجود بالفعل في المصفوفة إلى النهاية. إذا لم يكن الحقل الذي يتم تعديله مصفوفة بالفعل، فسيتم استبداله بمصفوفة تحتوي على العناصر المحددة بالضبط.
وظيفة (المجال، ...)
المتوسط ​​(الحقل) قم بإنشاء كائن AggregateField الذي يمكن استخدامه لحساب متوسط ​​حقل محدد عبر نطاق من المستندات في مجموعة نتائج الاستعلام.
مجموع (حقل) قم بإنشاء كائن AggregateField الذي يمكن استخدامه لحساب مجموع حقل محدد عبر نطاق من المستندات في مجموعة نتائج الاستعلام.
وظيفة (مسار الحقل، ...)
ترتيب حسب (fieldPath، DirectionStr) ينشئ QueryOrderByConstraint الذي يقوم بفرز نتيجة الاستعلام حسب الحقل المحدد، اختياريًا بترتيب تنازلي بدلاً من تصاعدي. ملاحظة: المستندات التي لا تحتوي على الحقل المحدد لن تكون موجودة في نتيجة الاستعلام.
حيث (fieldPath، opStr، القيمة) ينشئ QueryFieldFilterConstraint الذي يفرض أن المستندات يجب أن تحتوي على الحقل المحدد وأن القيمة يجب أن تستوفي قيد العلاقة المقدم.
وظيفة (القيم الميدانية، ...)
endAt(fieldValues) ينشئ QueryEndAtConstraint الذي يعدل مجموعة النتائج لتنتهي عند الحقول المتوفرة بالنسبة لترتيب الاستعلام. يجب أن يتطابق ترتيب قيم الحقول مع ترتيب الترتيب حسب عبارات الاستعلام.
endBefore(fieldValues) ينشئ QueryEndAtConstraint الذي يعدل مجموعة النتائج لتنتهي قبل الحقول المتوفرة بالنسبة لترتيب الاستعلام. يجب أن يتطابق ترتيب قيم الحقول مع ترتيب الترتيب حسب عبارات الاستعلام.
ابدأ بعد (قيم الحقل) ينشئ QueryStartAtConstraint الذي يعدل مجموعة النتائج لتبدأ بعد الحقول المتوفرة بالنسبة لترتيب الاستعلام. يجب أن يتطابق ترتيب قيم الحقول مع ترتيب الترتيب حسب عبارات الاستعلام.
البدء عند (قيم الحقل) ينشئ QueryStartAtConstraint الذي يعدل مجموعة النتائج للبدء في الحقول المتوفرة المتعلقة بترتيب الاستعلام. يجب أن يتطابق ترتيب قيم الحقول مع ترتيب الترتيب حسب عبارات الاستعلام.
وظيفة (مدير الفهرس، ...)
حذفAllPersistentCacheIndexes(indexManager) يزيل كافة فهارس ذاكرة التخزين المؤقت المستمرة. يرجى ملاحظة أن هذه الوظيفة ستحذف أيضًا الفهارس التي تم إنشاؤها بواسطة setIndexConfiguration() ، والتي تم إهمالها.
ديبليبرسستينتكاتشيإنديكس أوتوكرييشن (إندكس ماناجر) يتوقف عن إنشاء فهارس ذاكرة التخزين المؤقت المستمرة تلقائيًا لتنفيذ الاستعلام المحلي. الفهارس التي تم إنشاؤها عن طريق استدعاء enablePersistentCacheIndexAutoCreation() لا تزال سارية المفعول.
تمكين PersistentCacheIndexAutoCreation (indexManager) تمكين SDK من إنشاء فهارس ذاكرة التخزين المؤقت المستمرة تلقائيًا لتنفيذ الاستعلام المحلي عندما تعتقد SDK أن فهارس ذاكرة التخزين المؤقت يمكن أن تساعد في تحسين الأداء. يتم تعطيل هذه الميزة بشكل افتراضي.
الدالة (يسار،...)
مجاميع الحقل يساوي (يسار، يمين) يقارن حقلين "AggregateField". "حالات المساواة.
مجاميعQuerySnapshotEqual (يسار، يمين) يقارن بين مثيلين AggregateQuerySnapshot لتحقيق المساواة. يعتبر مثيلا AggregateQuerySnapshot "متساويين" إذا كان لديهما استعلامات أساسية تقارن البيانات المتساوية والبيانات نفسها.
استعلام متساوي (يسار، يمين) يُرجع صحيحًا إذا كانت الاستعلامات المقدمة تشير إلى نفس المجموعة وتطبق نفس القيود.
refEqual (يسار، يمين) يُرجع صحيحًا إذا كانت المراجع المقدمة متساوية.
لقطة متساوية (يسار، يمين) يُرجع صحيحًا إذا كانت اللقطات المقدمة متساوية.
وظيفة (الحد، ...)
الحد (الحد) يقوم بإنشاء QueryLimitConstraint الذي يقوم بإرجاع المستندات المطابقة الأولى فقط.
ليميتتولاست(الحد) يقوم بإنشاء QueryLimitConstraint الذي يقوم بإرجاع المستندات المطابقة الأخيرة فقط. يجب عليك تحديد عبارة orderBy واحدة على الأقل لاستعلامات limitToLast ، وإلا فسيتم طرح استثناء أثناء التنفيذ.
وظيفة (مستوى السجل، ...)
setLogLevel(مستوى السجل) يضبط إسهاب سجلات Cloud Firestore (التصحيح أو الخطأ أو الصمت).
وظيفة (ن، ...)
زيادة (ن) تُرجع قيمة خاصة يمكن استخدامها مع setDoc() أو updateDoc() والتي تخبر الخادم بزيادة القيمة الحالية للحقل بالقيمة المحددة. إذا كان المعامل أو قيمة الحقل الحالية تستخدم دقة الفاصلة العائمة، فإن جميع العمليات الحسابية تتبع دلالات IEEE 754. إذا كانت كلتا القيمتين أعدادًا صحيحة، فإن القيم الموجودة خارج نطاق الأرقام الآمنة لجافا سكريبت (من Number.MIN_SAFE_INTEGER إلى Number.MAX_SAFE_INTEGER ) تكون أيضًا عرضة لفقدان الدقة. علاوة على ذلك، بمجرد معالجتها بواسطة الواجهة الخلفية لـ Firestore، يتم تحديد جميع عمليات الأعداد الصحيحة بين -2^63 و2^63-1. إذا لم تكن قيمة الحقل الحالية من النوع number ، أو إذا لم يكن الحقل موجودًا بعد، فسيقوم التحويل بتعيين الحقل إلى القيمة المحددة.
وظيفة (الاستعلام، ...)
getAggregateFromServer(استعلام، CollectSpec) لحساب التجميعات المحددة على المستندات الموجودة في مجموعة النتائج للاستعلام المحدد دون تنزيل المستندات فعليًا. يعتبر استخدام هذه الوظيفة لإجراء عمليات التجميع فعالاً لأنه يتم تنزيل قيم التجميع النهائية فقط، وليس بيانات المستندات. يمكن لهذه الوظيفة إجراء مجموعات من المستندات في الحالات التي تكون فيها مجموعة النتائج كبيرة بشكل يمنع تنزيلها بالكامل (آلاف المستندات). يتم عرض النتيجة المستلمة من الخادم، دون تغيير، دون مراعاة أي حالة محلية. أي أن المستندات الموجودة في ذاكرة التخزين المؤقت المحلية لا تؤخذ في الاعتبار، ولا تتم مزامنة التعديلات المحلية مع الخادم بعد. ولا يتم استخدام النتائج التي تم تنزيلها مسبقًا، إن وجدت. يتضمن كل استدعاء لهذه الوظيفة بالضرورة رحلة ذهابًا وإيابًا إلى الخادم.
getCountFromServer(استعلام) حساب عدد المستندات في مجموعة النتائج للاستعلام المحدد دون تنزيل المستندات فعليًا. يعتبر استخدام هذه الوظيفة لحساب عدد المستندات أمرًا فعالاً لأنه يتم تنزيل العدد النهائي فقط، وليس بيانات المستندات. يمكن لهذه الوظيفة حساب المستندات في الحالات التي تكون فيها مجموعة النتائج كبيرة بشكل يمنع تنزيلها بالكامل (آلاف المستندات). يتم عرض النتيجة المستلمة من الخادم، دون تغيير، دون مراعاة أي حالة محلية. أي أن المستندات الموجودة في ذاكرة التخزين المؤقت المحلية لا تؤخذ في الاعتبار، ولا تتم مزامنة التعديلات المحلية مع الخادم بعد. ولا يتم استخدام النتائج التي تم تنزيلها مسبقًا، إن وجدت. يتضمن كل استدعاء لهذه الوظيفة بالضرورة رحلة ذهابًا وإيابًا إلى الخادم.
الحصول على المستندات (الاستعلام) ينفذ الاستعلام ويعيد النتائج في صورة QuerySnapshot . ملاحظة: يحاول getDocs() توفير بيانات محدثة عندما يكون ذلك ممكنًا عن طريق انتظار البيانات من الخادم، ولكنه قد يقوم بإرجاع البيانات المخزنة مؤقتًا أو يفشل إذا كنت غير متصل بالإنترنت ولا يمكن الوصول إلى الخادم. لتحديد هذا السلوك، قم باستدعاء getDocsFromCache() أو getDocsFromServer() .
getDocsFromCache(استعلام) ينفذ الاستعلام ويعيد النتائج على هيئة QuerySnapshot من ذاكرة التخزين المؤقت. إرجاع مجموعة نتائج فارغة إذا لم يتم تخزين المستندات المطابقة للاستعلام مؤقتًا حاليًا.
getDocsFromServer(استعلام) تنفيذ الاستعلام وإرجاع النتائج في صورة QuerySnapshot من الخادم. إرجاع خطأ إذا كانت الشبكة غير متوفرة.
onSnapshot (استعلام، مراقب) إرفاق مستمع لأحداث QuerySnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . يمكن إلغاء المستمع عن طريق استدعاء الوظيفة التي يتم إرجاعها عند استدعاء onSnapshot . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
onSnapshot (استعلام، خيارات، مراقب) إرفاق مستمع لأحداث QuerySnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . يمكن إلغاء المستمع عن طريق استدعاء الوظيفة التي يتم إرجاعها عند استدعاء onSnapshot . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
onSnapshot(استعلام، onNext، onError، onCompletion) إرفاق مستمع لأحداث QuerySnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . يمكن إلغاء المستمع عن طريق استدعاء الوظيفة التي يتم إرجاعها عند استدعاء onSnapshot . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
onSnapshot(استعلام، خيارات، onNext، onError، onCompletion) إرفاق مستمع لأحداث QuerySnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . يمكن إلغاء المستمع عن طريق استدعاء الوظيفة التي يتم إرجاعها عند استدعاء onSnapshot . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
الاستعلام (الاستعلام، عامل التصفية المركب، الاستعلام عن القيود) ينشئ مثيلًا جديدًا غير قابل للتغيير للاستعلام يتم توسيعه ليشمل أيضًا قيود استعلام إضافية.
الاستعلام (الاستعلام، الاستعلام القيود) ينشئ مثيلًا جديدًا غير قابل للتغيير للاستعلام يتم توسيعه ليشمل أيضًا قيود استعلام إضافية.
وظيفة (الاستعلام، ...)
و(قيود الاستعلام) يقوم بإنشاء QueryCompositeFilterConstraint جديد وهو عبارة عن اقتران لقيود عامل التصفية المحددة. يتضمن مرشح الاقتران مستندًا إذا كان يلبي جميع عوامل التصفية المحددة.
أو (قيود الاستعلام) يقوم بإنشاء QueryCompositeFilterConstraint جديد وهو عبارة عن انفصال عن قيود عامل التصفية المحددة. يشتمل مرشح الانفصال على مستند إذا كان يلبي أيًا من المرشحات المحددة.
وظيفة (مرجع، ...)
addDoc(مرجع، بيانات) أضف مستندًا جديدًا إلى CollectionReference المحدد بالبيانات المقدمة، وقم بتعيين معرف المستند إليه تلقائيًا.
المجموعة (المرجع، المسار، شرائح المسار) الحصول على مثيل CollectionReference الذي يشير إلى مجموعة فرعية من reference في المسار النسبي المحدد.
المجموعة (المرجع، المسار، شرائح المسار) الحصول على مثيل CollectionReference الذي يشير إلى مجموعة فرعية من reference في المسار النسبي المحدد.
حذف المستند (المرجع) يحذف المستند المشار إليه بواسطة DocumentReference المحدد.
مستند (مرجع، مسار، أجزاء المسار) الحصول على مثيل DocumentReference الذي يشير إلى مستند ضمن reference في المسار النسبي المحدد. إذا لم يتم تحديد أي مسار، فسيتم استخدام معرف فريد يتم إنشاؤه تلقائيًا لـ DocumentReference الذي تم إرجاعه.
مستند (مرجع، مسار، أجزاء المسار) الحصول على مثيل DocumentReference الذي يشير إلى مستند ضمن reference في المسار النسبي المحدد.
الحصول على الوثيقة (المرجع) يقرأ الوثيقة المشار إليها بهذا DocumentReference . ملاحظة: يحاول getDoc() توفير بيانات محدثة عندما يكون ذلك ممكنًا عن طريق انتظار البيانات من الخادم، ولكنه قد يقوم بإرجاع البيانات المخزنة مؤقتًا أو يفشل إذا كنت غير متصل بالإنترنت ولا يمكن الوصول إلى الخادم. لتحديد هذا السلوك، قم باستدعاء getDocFromCache() أو getDocFromServer() .
getDocFromCache(مرجع) يقرأ المستند المشار إليه بهذا DocumentReference من ذاكرة التخزين المؤقت. إرجاع خطأ إذا لم يتم تخزين المستند مؤقتًا حاليًا.
getDocFromServer(مرجع) يقرأ المستند المشار إليه بهذا DocumentReference من الخادم. إرجاع خطأ إذا كانت الشبكة غير متوفرة.
onSnapshot (مرجع، مراقب) إرفاق مستمع لأحداث DocumentSnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
onSnapshot (مرجع، خيارات، مراقب) إرفاق مستمع لأحداث DocumentSnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
onSnapshot(مرجع، onNext، onError، onCompletion) إرفاق مستمع لأحداث DocumentSnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
onSnapshot(مرجع، خيارات، onNext، onError، onCompletion) إرفاق مستمع لأحداث DocumentSnapshot . يمكنك إما تمرير عمليات رد نداء onNext و onError فردية أو تمرير كائن مراقب واحد مع عمليات رد النداء next error . ملاحظة: على الرغم من إمكانية توفير رد اتصال onCompletion ، إلا أنه لن يتم استدعاؤه أبدًا لأن دفق اللقطة لا ينتهي أبدًا.
setDoc(مرجع، بيانات) يكتب إلى الوثيقة المشار إليها في هذا DocumentReference . إذا لم يكن المستند موجودًا بعد، فسيتم إنشاؤه.
setDoc(مرجع، بيانات، خيارات) يكتب إلى المستند المشار إليه بواسطة DocumentReference المحدد. إذا لم يكن المستند موجودًا بعد، فسيتم إنشاؤه. إذا قمت بتوفير merge أو mergeFields ، فيمكن دمج البيانات المقدمة في مستند موجود.
updateDoc(مرجع، بيانات) يقوم بتحديث الحقول في المستند المشار إليه بواسطة DocumentReference المحدد. سوف يفشل التحديث إذا تم تطبيقه على مستند غير موجود.
UpdateDoc(مرجع، حقل، قيمة، moreFieldsAndValues) تحديثات الحقول في المستند المشار إليه بواسطة DocumentReference المحدد. سيفشل التحديث إذا تم تطبيقه على مستند غير موجود. يمكن تحديث الحقول المتداخلة من خلال توفير سلاسل مسار حقل مفصولة بنقاط أو من خلال توفير كائنات FieldPath .
الوظيفة (الإعدادات، ...)
ذاكرة التخزين المؤقت المحلية (الإعدادات) إنشاء مثيل لـ MemoryLocalCache . يمكن تعيين المثيل على FirestoreSettings.cache لإخبار SDK بطبقة ذاكرة التخزين المؤقت التي يجب استخدامها.
MemoryLruGarbageCollector (الإعدادات) إنشاء مثيل لـ MemoryLruGarbageCollector . يمكن تحديد حجم الهدف كجزء من معلمة الإعداد. سيبدأ المجمع في حذف المستندات بمجرد أن يتجاوز حجم ذاكرة التخزين المؤقت الحجم المحدد. حجم ذاكرة التخزين المؤقت الافتراضي هو 40 ميجابايت (40 * 1024 * 1024 بايت).
المستمرLocalCache (الإعدادات) إنشاء مثيل لـ PersistentLocalCache . يمكن تعيين المثيل على FirestoreSettings.cache لإخبار SDK بطبقة ذاكرة التخزين المؤقت التي يجب استخدامها. لا يمكن استخدام ذاكرة التخزين المؤقت المستمرة في بيئة Node.js.
استمرارSingleTabManager (الإعدادات) إنشاء مثيل لـ PersistentSingleTabManager .
وظيفة (لقطة، ...)
النهاية في (لقطة) ينشئ QueryEndAtConstraint الذي يعدل مجموعة النتائج لتنتهي عند المستند المقدم (شاملاً). موضع النهاية يتعلق بترتيب الاستعلام. يجب أن يحتوي المستند على كافة الحقول المتوفرة في ترتيب الاستعلام.
النهاية قبل (لقطة) ينشئ QueryEndAtConstraint الذي يعدل مجموعة النتائج لتنتهي قبل المستند المقدم (حصريًا). موضع النهاية يتعلق بترتيب الاستعلام. يجب أن يحتوي المستند على كافة الحقول المتوفرة في ترتيب الاستعلام.
ابدأ بعد (لقطة) ينشئ QueryStartAtConstraint الذي يعدل مجموعة النتائج للبدء بعد المستند المقدم (حصريًا). موضع البداية يتعلق بترتيب الاستعلام. يجب أن يحتوي المستند على كافة الحقول المتوفرة في ترتيب الاستعلام.
البداية في (لقطة) ينشئ QueryStartAtConstraint الذي يعدل مجموعة النتائج للبدء في المستند المقدم (ضمناً). موضع البداية يتعلق بترتيب الاستعلام. يجب أن يحتوي المستند على كافة الحقول المتوفرة في orderBy هذا الاستعلام.

الطبقات

فصل وصف
AggregateField يمثل تجميعًا يمكن تنفيذه بواسطة Firestore.
AggregateQuerySnapshot نتائج تنفيذ استعلام التجميع.
بايت كائن غير قابل للتغيير يمثل مجموعة من البايتات.
مرجع المجموعة يمكن استخدام كائن CollectionReference لإضافة المستندات والحصول على مراجع المستندات والاستعلام عن المستندات (باستخدام query() ).
وثيقة مرجعية يشير DocumentReference إلى موقع المستند في قاعدة بيانات Firestore ويمكن استخدامه لكتابة الموقع أو قراءته أو الاستماع إليه. قد يكون المستند الموجود في الموقع المشار إليه موجودًا أو غير موجود.
DocumentSnapshot يحتوي DocumentSnapshot على البيانات المقروءة من مستند موجود في قاعدة بيانات Firestore. يمكن استخراج البيانات باستخدام .data() أو .get(<field>) للحصول على حقل معين. بالنسبة إلى DocumentSnapshot التي تشير إلى مستند غير موجود، فإن أي وصول للبيانات سيرجع "غير محدد". يمكنك استخدام الطريقة exists() للتحقق بشكل صريح من وجود المستند.
مسار الحقل يشير FieldPath إلى حقل في المستند. قد يتكون المسار من اسم حقل واحد (يشير إلى حقل المستوى الأعلى في المستند)، أو قائمة بأسماء الحقول (يشير إلى حقل متداخل في المستند). قم بإنشاء FieldPath من خلال توفير أسماء الحقول. إذا تم توفير أكثر من اسم حقل واحد، فسيشير المسار إلى حقل متداخل في المستند.
قيمة الحقل القيم الحارسة التي يمكن استخدامها عند كتابة حقول المستند باستخدام set() أو update() .
فايرستور واجهة خدمة Cloud Firestore. لا تستدعي هذا المنشئ مباشرة. بدلاً من ذلك، استخدم getFirestore() .
FirestoreError خطأ تم إرجاعه بواسطة عملية Firestore.
نقطة جغرافية كائن ثابت يمثل موقعًا جغرافيًا في Firestore. يتم تمثيل الموقع كزوج من خطوط الطول والعرض. تقع قيم خط العرض في نطاق [-90، 90]. تقع قيم خط الطول في نطاق [-180، 180].
LoadBundleTask يمثل مهمة تحميل حزمة Firestore. فهو يوفر التقدم في تحميل الحزمة، بالإضافة إلى إكمال المهام وأحداث الخطأ. واجهة برمجة التطبيقات متوافقة مع Promise<LoadBundleTaskProgress> .
PersistentCacheIndexManager PersistentCacheIndexManager لتكوين فهارس ذاكرة التخزين المؤقت المستمرة المستخدمة لتنفيذ الاستعلام المحلي. للاستخدام، اتصل بـ getPersistentCacheIndexManager() للحصول على مثيل.
استفسار يشير Query إلى استعلام يمكنك قراءته أو الاستماع إليه. يمكنك أيضًا إنشاء كائنات Query محسنة عن طريق إضافة المرشحات والترتيب.
QueryCompositeFilterConstraint يتم استخدام QueryCompositeFilterConstraint لتضييق نطاق مجموعة المستندات التي يتم إرجاعها بواسطة استعلام Firestore عن طريق إجراء عملية OR أو AND المنطقية لـ QueryFieldFilterConstraint المتعددة s أو QueryCompositeFilterConstraint س. يتم إنشاء QueryCompositeFilterConstraint عن طريق استدعاء or() أو and() ويمكن بعد ذلك تمريرها إلى query() لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryCompositeFilterConstraint .
QueryConstraint يتم استخدام QueryConstraint لتضييق نطاق مجموعة المستندات التي يتم إرجاعها بواسطة استعلام Firestore. يتم إنشاء QueryConstraint عن طريق استدعاء Where() ، ترتيب حسب() ، تبدأ في() ، ابدأ بعد () ، النهاية قبل () ، يغلق عند مستوى() ، حد() و LimitToLast() ويمكن بعد ذلك تمريرها إلى query() لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryConstraint هذا.
QueryDocumentSnapshot يحتوي QueryDocumentSnapshot على بيانات تمت قراءتها من مستند في قاعدة بيانات Firestore كجزء من الاستعلام. الوثيقة مضمونة الوجود ويمكن استخراج بياناتها باستخدام .data() أو .get(<field>) للحصول على حقل معين. يقدم QueryDocumentSnapshot نفس سطح واجهة برمجة التطبيقات (API) الذي يوفره DocumentSnapshot . نظرًا لأن نتائج الاستعلام تحتوي على مستندات موجودة فقط، فستكون الخاصية exists دائمًا صحيحة ولن تُرجع data() أبدًا القيمة "غير محددة".
QueryEndAtConstraint يتم استخدام QueryEndAtConstraint لاستبعاد المستندات من نهاية مجموعة النتائج التي يتم إرجاعها بواسطة استعلام Firestore. يتم إنشاء QueryEndAtConstraint عن طريق استدعاء endAt() أو endBefore() ويمكن بعد ذلك تمريرها إلى query() لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryEndAtConstraint هذا.
QueryFieldFilterConstraint يتم استخدام QueryFieldFilterConstraint لتضييق نطاق مجموعة المستندات التي يتم إرجاعها بواسطة استعلام Firestore عن طريق التصفية في حقل مستند واحد أو أكثر. يتم إنشاء QueryFieldFilterConstraint عن طريق استدعاء Where() ويمكن بعد ذلك تمريرها إلى query() لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryFieldFilterConstraint هذا.
QueryLimitConstraint يتم استخدام QueryLimitConstraint للحد من عدد المستندات التي يتم إرجاعها بواسطة استعلام Firestore. يتم إنشاء QueryLimitConstraint عن طريق استدعاء Limit() أو LimitToLast() ويمكن بعد ذلك تمريرها إلى query() لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryLimitConstraint هذا.
الاستعلام حسب القيد يتم استخدام QueryOrderByConstraint لفرز مجموعة المستندات التي يتم إرجاعها بواسطة استعلام Firestore. يتم إنشاء QueryOrderByConstraint عن طريق استدعاء orderBy() ويمكن بعد ذلك تمريرها إلى query() لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryOrderByConstraint هذا. ملاحظة: المستندات التي لا تحتوي على حقل orderBy لن تكون موجودة في نتيجة الاستعلام.
QuerySnapshot يحتوي QuerySnapshot على كائنات DocumentSnapshot أو أكثر من المستندات التي تمثل نتائج الاستعلام. يمكن الوصول إلى المستندات كصفيف عبر خاصية docs أو تعدادها باستخدام طريقة forEach . يمكن تحديد عدد المستندات عبر الخصائص empty size .
QueryStartAtconstraint يتم استخدام QueryStartAtConstraint لاستبعاد المستندات من بداية مجموعة النتائج التي تم إرجاعها بواسطة استعلام Firestore. يتم إنشاء QueryStartAtConstraint S عن طريق استدعاء StartAt () أو startAfter () ويمكن بعد ذلك تمريره إلى Query () لإنشاء مثيل استعلام جديد يحتوي أيضًا على هذا QueryStartAtConstraint .
Snapshotmetadata البيانات الوصفية حول لقطة ، تصف حالة اللقطة.
الطابع الزمني يمثل Timestamp نقطة زمنية مستقلة عن أي منطقة زمنية أو تقويم ، ممثلة كثوانات وكسور من الثواني بدقة نانو ثانية في وقت تعبير UTC. تم ترميزه باستخدام التقويم الجريجوري Proleptic الذي يمتد التقويم الغريغوري إلى الوراء إلى السنة الأولى. يتم ترميزه على افتراض أن جميع الدقائق يبلغ طولها 60 ثانية ، على سبيل المثال ، يتم "تلطيخ" ، بحيث لا يلزم وجود طاولة ثانية للتفسير. النطاق من 0001-01-01T00: 00: 00Z إلى 9999-12-31T23: 59: 59.99999999z. للحصول على أمثلة ومزيد من المواصفات ، راجع تعريف الطابع الزمني .
عملية إشارة إلى معاملة. يوفر كائن Transaction الذي تم تمريره إلى updateFunction المعاملة طرقًا لقراءة وكتابة البيانات في سياق المعاملة. انظر RunTransaction () .
WriteBatch دفعة الكتابة ، تستخدم لأداء عمليات كتابة متعددة كوحدة ذرية واحدة. يمكن الحصول على كائن WriteBatch عن طريق الاتصال بـ WriteBatch () . يوفر طرقًا لإضافة عمليات الكتابة إلى مجموعة الكتابة. لن يتم ارتكاب أي من الكتابة (أو مرئيًا محليًا) حتى يتم استدعاء WriteBatch.Commit () .

واجهات

واجهه المستخدم وصف
الركام يحدد مجموعة من التجميعات وأسماء المستعار.
DocumentChange يمثل برنامج DocumentChange تغييرًا في المستندات التي تطابق الاستعلام. أنه يحتوي على المستند المتأثر ونوع التغيير الذي حدث.
DocumentData بيانات المستند (للاستخدام مع setDoc () ) يتكون من الحقول المعينة للقيم.
ExperimalongPollingOptions الخيارات التي تقوم بتكوين نقل الشبكة الأساسي في SDK (WebChannel) عند استخدام الصب الطويل. ملاحظة: هذه الواجهة "تجريبية" وهي عرضة للتغيير. انظر FirestoreSettings.experimentalAutoDetectLongPolling ، FirestoreSettings.experimentalForceLongPolling ، و FirestoreSettings.experimentalLongPollingOptions .
FireStoredataconverter المحول المستخدم من قبل withConverter() لتحويل كائنات المستخدم من نوع AppModelType إلى بيانات firestore من نوع DbModelType . يتيح لك استخدام المحول تحديد وسيطات النوع العام عند تخزين واسترداد الكائنات من Firestore. في هذا السياق ، "AppModel" عبارة عن فئة تستخدم في تطبيق لتعبئة المعلومات والوظائف ذات الصلة. يمكن أن يكون لمثل هذا الفصل ، على سبيل المثال ، خصائص مع أنواع البيانات المعقدة المتداخلة ، والخصائص المستخدمة في المذكرة ، وخصائص الأنواع التي لا تدعمها Firestore (مثل symbol و bigint ) ، ووظائف المساعدة التي تؤدي عمليات مركب. هذه الفئات ليست مناسبة و/أو ممكنة تخزينها في قاعدة بيانات Firestore. بدلاً من ذلك ، يجب تحويل مثيلات من هذه الفئات إلى "كائنات JavaScript القديمة البسيطة" (POJOS) ذات الخصائص البدائية بشكل حصري ، والتي يحتمل أن تكون متداخلة داخل بوجوس أو صفائف من Pojos. في هذا السياق ، يشار إلى هذا النوع باسم "DBModel" وسيكون كائنًا مناسبًا للاستمرار في Firestore. للراحة ، يمكن للتطبيقات تنفيذ FirestoreDataConverter وتسجيل المحول مع كائنات Firestore ، مثل DocumentReference أو Query ، لتحويل AppModel تلقائيًا إلى DbModel عند التخزين في Firestore ، وتحويل DbModel إلى AppModel عند الاسترداد من Firestore.
firestoresettings يحدد التكوينات المخصصة لمثيل سحابة Firestore الخاص بك. يجب عليك تعيين هذه قبل استدعاء أي طرق أخرى.
فِهرِس (بيتا) تعريف SDK لمؤشر Firestore.
indexConfiguration (بيتا) قائمة من فهارس Firestore لتسريع تنفيذ الاستعلام المحلي. انظر تنسيق JSON للحصول على وصف لتنسيق تعريف الفهرس.
Indexfield (بيتا) عنصر حقل واحد في تكوين الفهرس.
loadBundleTaskProgress يمثل تحديث التقدم أو الحالة النهائية من حزم التحميل.
MemoryCachesettings كائن الإعدادات لتكوين مثيل MemoryLocalCache .
MemoryeAgerGarbageCollector يقوم جامع القمامة بحذف المستندات كلما لم تكن جزءًا من أي استعلامات نشطة ، وليس لها طفرات محلية مرتبطة بها. يحاول هذا المجمع ضمان أدنى آثار أقدام الذاكرة من SDK ، في خطر عدم تخزين المستندات للتخزين المؤقت للاستعلامات غير المتصلة بالإنترنت أو للاستعلامات المباشرة إلى ذاكرة التخزين المؤقت. استخدم وظيفة المصنع لإنشاء مثيل لهذا المجمع.
MemoryLocalcache يوفر ذاكرة التخزين المؤقت في الذاكرة إلى SDK. هذا هو ذاكرة التخزين المؤقت الافتراضية ما لم يتم تكوينها بشكل صريح. للاستخدام ، قم بإنشاء مثيل باستخدام وظيفة المصنع ، ثم قم بتعيين المثيل على FirestoreSettings.cache و initializeFirestore باستخدام كائن الإعدادات.
MemoryLrugarBageCollector يقوم جامع القمامة بحذف المستندات الأقل استخدامًا بشكل أقل في دفعات متعددة. تم تكوين هذا المجمع بحجم مستهدف ، وسيؤدي مجموعة فقط عندما تتجاوز المستندات المخزنة مؤقتًا الحجم المستهدف. إنه يتجنب الاستعلام عن الواجهة الخلفية المتكررة لنفس الاستعلام أو المستند ، في خطر وجود بصمة أكبر للذاكرة. استخدم وظيفة المصنع لإنشاء مثيل لهذا جامع.
تعليمات الإعدادات التي يمكن تمريرها لتمكين enableIndexedDbPersistence() لتكوين ثبات Firestore. لا يمكن استخدام الثبات في بيئة node.js.
PROSESTIONCACHESETTINGS كائن الإعدادات لتكوين مثيل PersistentLocalCache . لا يمكن استخدام ذاكرة التخزين المؤقت المستمرة في بيئة Node.js.
PROSESTIONLOCALCACHE يوفر ذاكرة التخزين المؤقت المستمرة المدعومة من قبل الفهرسة إلى SDK. للاستخدام ، قم بإنشاء مثيل باستخدام وظيفة المصنع ، ثم قم بتعيين المثيل على FirestoreSettings.cache و initializeFirestore باستخدام كائن الإعدادات.
perfectmultipletabmanager مدير علامة تبويب يدعم علامات تبويب متعددة. ستقوم SDK بمزامنة الاستعلامات والطفرات التي تم إجراؤها عبر جميع علامات التبويب باستخدام SDK.
PrethistentSingletabmanager مدير علامة تبويب يدعم علامة تبويب واحدة فقط ، لن يتم تنفيذ أي مزامنة عبر علامات التبويب.
pratistentsingletabmanagersettings اكتب لتكوين مثيل PersistentSingleTabManager .
Snapshotlistenoptions كائن خيارات يمكن تمريره إلى onsnapshot () و QuerySnapshot.docchanges () للتحكم في أنواع التغييرات التي يجب تضمينها في مجموعة النتائج.
لقطات الخيارات التي تقوم بتكوين كيفية استرداد البيانات من DocumentSnapshot (على سبيل المثال ، السلوك المطلوب لمضادات الزمن الخادم التي لم يتم تعيينها بعد على قيمتها النهائية).
المعاملات خيارات لتخصيص سلوك المعاملة.
إلغاء الاشتراك وظيفة تم إرجاعها بواسطة onSnapshot() التي تزيل المستمع عند الاحتجاج بها.

المتغيرات

عامل وصف
cache_size_unlimited ثابت يستخدم للإشارة إلى أن مجموعة القمامة LRU يجب تعطيلها. قم بتعيين هذه القيمة على أنها cacheSizeBytes على الإعدادات التي تم تمريرها إلى مثيل Firestore .

اكتب الأسماء المستعارة

اكتب الاسم المستعار وصف
addprefixtokeys إرجاع خريطة جديدة حيث يتم توجيه كل مفتاح مع المفتاح الخارجي الملحق بنقطة.
ascregatefieldtype اتحاد جميع أنواع AggregateField التي تدعمها Firestore.
الركام نوع من المفاتيح التي يتم أخذ مفاتيحها من AggregateSpec ، والتي تكون قيمها نتيجة التجميع التي يؤديها AggregateField المقابل من AggregateSpec الإدخال.
aggregateType نوع الاتحاد الذي يمثل النوع الكلي المراد تنفيذه.
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 invalid': حدد العميل وسيطة غير صالحة. لاحظ أن هذا يختلف عن "الشرط الفاشل". يشير "argument غير صالح" إلى الحجج التي تكون مشكلة بغض النظر عن حالة النظام (على سبيل المثال اسم حقل غير صالح). - "الموعد النهائي الموعد النهائي": انتهت الموعد النهائي قبل انتهاء العملية. بالنسبة للعمليات التي تغير حالة النظام ، قد يتم إرجاع هذا الخطأ حتى إذا كانت العملية قد اكتملت بنجاح. على سبيل المثال ، كان من الممكن تأخير استجابة ناجحة من الخادم لفترة طويلة بما يكفي لإنهاء الموعد النهائي. - "غير مؤسس": لم يتم العثور على بعض المستند المطلوب. - "موجود بالفعل": بعض المستندات التي حاولنا إنشاءها موجودة بالفعل. - "الإذن المنقولة": لا يحتوي المتصل على إذن لتنفيذ العملية المحددة. -"الموارد التي يتم تنقيتها": تم استنفاد بعض الموارد ، وربما حصة لكل مستخدم ، أو ربما نظام الملفات بأكمله خارج الفضاء. - "الإثارة الفاشلة": تم رفض العملية لأن النظام ليس في حالة مطلوبة لتنفيذ العملية. - "تم إحباط": تم إحباط العملية ، وعادةً ما تكون بسبب مسألة التزامن مثل إحباط المعاملات ، وما إلى ذلك- "خارج المدى": تمت محاولة العملية تجاوز النطاق الصحيح. - 'Unecteded': لم يتم تنفيذ العملية أو عدم دعمها/تمكينها. - "داخلي": الأخطاء الداخلية. تعني أن بعض الثوابات المتوقعة من قبل النظام الأساسي قد تم كسرها. إذا رأيت أحد هذه الأخطاء ، فسيكون هناك شيء مكسور للغاية. - "غير متوفر": الخدمة غير متوفرة حاليًا. هذا على الأرجح حالة عابرة ويمكن تصحيحها من خلال إعادة المحاولة باستخدام التراجع. - "فقدان البيانات": فقدان البيانات أو الفساد غير قابل للاسترداد. - "غير مصادقة": لا يحتوي الطلب على بيانات اعتماد مصادقة صالحة للعملية.
FireStorelocalcache نوع الاتحاد من جميع طبقة ذاكرة التخزين المؤقت SDK المدعومة.
الاستماع صف المصدر يستمع الاستماع إلى. قم بتعيين default للاستماع إلى كل من ذاكرة التخزين المؤقت وتغييرات الخادم. قم بتعيين cache للاستماع إلى التغييرات في ذاكرة التخزين المؤقت فقط.
MemoryGarbageCollector نوع الاتحاد من جميع جامعي Gabage للذاكرة ذاكرة التخزين المؤقت المحلية.
NETTERUPDATEFIELDS لكل حقل (على سبيل المثال "شريط") ، ابحث عن جميع المفاتيح المتداخلة (على سبيل المثال { 'bar.baz': t1 ، 'bar.qux': t2 } ). تقاطعهم معًا لإنشاء خريطة واحدة تحتوي على جميع المفاتيح الممكنة التي يتم تمييزها جميعًا على أنها اختيارية
Orderbydirection يتم تحديد اتجاه شرط orderby () على أنه "desc" أو "ASC" (تنازلي أو تصاعدي).
partialwithfieldvalue على غرار TypeScript Partial<T> ، ولكنه يسمح بحذف الحقول المتداخلة وإصدار القيم الميدانية في قيم الممتلكات.
PROSESTIONTTABMANAGER اتحاد لجميع مديري علامات التبويب المتاحة.
بدائية الأنواع البدائية.
QueryConstrainttype يصف قيود الاستعلام المختلفة المتاحة في هذا SDK.
QueryFilterConstraint QueryFilterConstraint هو نوع الاتحاد المساعد الذي يمثل QueryfieldFilterConstraint و QueryCompositeFilterConstraint .
QuerynonfilterConstraint QueryNonFilterConstraint هو نوع من الاتحاد المساعد الذي يمثل QueryConstraints المستخدمة لتضييق أو طلب مجموعة المستندات ، ولكن لا يتم تصفية بشكل صريح على حقل المستند. يتم إنشاء QueryNonFilterConstraint S عن طريق استدعاء Orderby () ، تبدأ في() ، startafter () ، endbefore () ، يغلق عند مستوى() و limit () أو limittolast () ويمكن بعد ذلك تمريرها إلى الاستعلام () لإنشاء مثيل استعلام جديد يحتوي أيضًا على QueryConstraint .
setOptions كائن خيارات يقوم بتكوين سلوك setDoc () ومكالمات. يمكن تكوين هذه المكالمات لأداء دمج الحبيبية بدلاً من الكتابة فوق المستندات المستهدفة بالكامل من خلال توفير SetOptions من merge: true .
TaskState يمثل حالة مهام تحميل الحزمة. كل من "الخطأ" و "النجاح" هما حالة غرق: ستجهوب المهمة أو تكتمل ولن يكون هناك المزيد من التحديثات بعد الإبلاغ عنها.
UnionToEntersection إعطاء نوع الاتحاد U = T1 | T2 | ... ، إرجاع نوع متداخل (T1 & T2 & ...) . يستخدم الأنواع الشرطية الموزعة والاستدلال من الأنواع الشرطية. هذا يعمل لأن العديد من المرشحين لنفس النوع المتغير في المواقف المتغير المتغير يؤدي إلى استنتاج نوع التقاطع. https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inferek- -يكتب
تحديث البيانات تحديث البيانات (للاستخدام مع updatedoc () ) تتكون من مسارات الحقل (على سبيل المثال "foo" أو "foo.baz") تم تعيينها للقيم. الحقول التي تحتوي على نقاط مرجعية الحقول المتداخلة داخل المستند. يمكن تمرير القيم الميدانية في قيم الممتلكات.
WhateFilterop شروط التصفية في A Where () يتم تحديد جملة باستخدام الأوتار '& lt ؛' ، '& lt ؛ =' ، '==' ، '! =' ، '& gt ؛ =' ، '& gt ؛' ، 'array-contains' ، "في" ، "صفيفات الصفيف-أي" ، و "غير في".
WithfieldValue يتيح أن يتم تمرير القيم الحقل كقيمة خاصية مع الحفاظ على سلامة النوع.

وظيفة (التطبيق ، ...)

getFirestore (التطبيق)

إرجاع مثيل Firestore الافتراضي الموجود المرتبط بـ FireBaseApp المقدم . في حالة عدم وجود مثيل ، قم بتهيئة مثيل جديد بإعدادات افتراضية.

إمضاء:

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

حدود

معامل يكتب وصف
برنامج Firebaseapp مثيل FireBaseApp الذي يرتبط مثيل Firestore الذي تم إرجاعه.

عائدات:

فايرستور

مثيل Firestore الافتراضي للتطبيق المقدم.

getFirestore (التطبيق ، databaseid)

يتم توفير واجهة برمجة التطبيقات هذه كمعاينة للمطورين وقد تتغير بناءً على التعليقات التي نتلقاها. لا تستخدم واجهة برمجة التطبيقات هذه في بيئة الإنتاج.

إرجاع مثيل Firestore الموجود المرتبط بـ FireBaseApp المقدم . في حالة عدم وجود مثيل ، قم بتهيئة مثيل جديد بإعدادات افتراضية.

إمضاء:

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

حدود

معامل يكتب وصف
برنامج Firebaseapp مثيل FireBaseApp الذي يرتبط مثيل Firestore الذي تم إرجاعه.
DatabaseId خيط اسم قاعدة البيانات.

عائدات:

فايرستور

مثيل Firestore المسماة للتطبيق المقدم.

initializeFirestore (التطبيق ، الإعدادات ، databaseid)

تهيئة مثيل جديد لـ Firestore مع الإعدادات المقدمة. لا يمكن استدعاؤها إلا قبل أي وظيفة أخرى ، بما في ذلك getFirestore () . إذا كانت الإعدادات المخصصة فارغة ، فإن هذه الوظيفة تعادل استدعاء GetFirestore () .

إمضاء:

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

حدود

معامل يكتب وصف
برنامج Firebaseapp FirebaseApp الذي سيتم ربط مثال Firestore .
إعدادات firestoresettings كائن الإعدادات لتكوين مثيل Firestore .
DatabaseId خيط اسم قاعدة البيانات.

عائدات:

فايرستور

مثيل Firestore تهيئته حديثًا.

وظيفة (Firestore ، ...)

ClearIndexedDBPersistence (Firestore)

يمسح التخزين المستمر. ويشمل ذلك المعلق في الكتابة والوثائق المخزنة مؤقتًا.

يجب أن يتم استدعاؤها أثناء عدم بدء مثيل Firestore (بعد إنهاء التطبيق أو عند تهيئة التطبيق لأول مرة). عند بدء التشغيل ، يجب استدعاء هذه الوظيفة قبل وظائف أخرى (بخلاف initializeFirestore () أو getFirestore () )). إذا كان مثيل Firestore لا يزال قيد التشغيل ، فسيتم رفض الوعد برمز الخطأ failed-precondition .

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثال Firestore لمسح الثبات.

عائدات:

وعد <doud>

Promise الذي يتم حله عند مسح التخزين المستمر. خلاف ذلك ، يتم رفض الوعد بخطأ.

مجموعة (Firestore ، المسار ، المسار)

يحصل على مثيل 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 .
CollectionId خيط يحدد المجموعات للاستعلام. سيتم تضمين كل مجموعة أو جمعية فرعية مع هذا المعرف كجزء آخر من مساره. لا يمكن أن تحتوي على مائلة.

عائدات:

استفسار < documentData ، documentData >

Query الذي تم إنشاؤه .

ConnectFirestoreemulator (Firestore ، مضيف ، منفذ ، خيارات)

قم بتعديل هذه الحالة للتواصل مع محاكي Firestore Cloud.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore للتكوين للاتصال بالمحاكي.
يستضيف خيط مضيف المحاكي (على سبيل المثال: LocalHost).
ميناء رقم منفذ المحاكي (على سبيل المثال: 9000).
خيارات {mockusertoken؟: emulatormocktokenoptions | خيط؛ }

عائدات:

فارغ

عطل (Firestore)

يعطل استخدام الشبكة لهذه الحالة. يمكن إعادة تمكينه عبر Enablenetwork () . بينما يتم تعطيل الشبكة ، فإن أي مستمعين لقطات ، سيعيد مكالمات getDoc() أو getDocs() نتائج ذاكرة التخزين المؤقت ، وسيتم وضع أي عمليات كتابة حتى يتم استعادة الشبكة.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور

عائدات:

وعد <doud>

Promise يتم حله بمجرد تعطيل الشبكة.

DOC (Firestore ، Path ، PathSegments)

يحصل على مثيل DocumentReference الذي يشير إلى المستند في المسار المطلق المحدد.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور إشارة إلى مثيل الجذر Firestore .
طريق خيط مسار مفصل للخلع إلى وثيقة.
المسارات خيط[] شرائح المسار الإضافية التي سيتم تطبيقها بالنسبة للحجة الأولى.

عائدات:

وثيقة مرجعية < documentData ، documentData >

مثيل DocumentReference .

الاستثناءات

إذا كان المسار النهائي يحتوي على عدد فردي من الأجزاء ولم يشير إلى وثيقة.

EnableIndexedDbersistence (Firestore ، Prosistencestings)

ستتم إزالة هذه الوظيفة في إصدار رئيسي في المستقبل. بدلاً من ذلك ، قم بتعيين FirestoreSettings.localCache على مثيل من PersistentLocalCache لتشغيل ذاكرة التخزين المؤقت INSTINGEDDB. استدعاء هذه الوظيفة عند تحديد FirestoreSettings.localCache بالفعل ، سوف يلقي استثناء.

محاولات لتمكين التخزين المستمر ، إن أمكن.

عند الفشل ، سوف يرفض enableIndexedDbPersistence() الوعد أو رمي استثناء. هناك العديد من الأسباب التي تجعل ذلك قد يفشل ، والتي يمكن تحديدها بواسطة code على الخطأ.

* الفشل الفاشل: التطبيق مفتوح بالفعل في علامة تبويب متصفح أخرى. * غير مفيدة: المستعرض لا يتوافق مع تنفيذ الثبات في وضع عدم الاتصال.

لاحظ أنه حتى بعد الفشل ، ستبقى مثيل Firestore قابلاً للاستخدام ، ولكن سيتم تعطيل الثبات غير المتصلة بالإنترنت.

لا يمكن استخدام الثبات في بيئة node.js.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثال Firestore لتمكين الثبات ل.
تعليمات تعليمات كائن الإعدادات الاختيارية لتكوين الثبات.

عائدات:

وعد <doud>

Promise الذي يمثل بنجاح تمكين التخزين المستمر.

enablemultitaBindexedDbersistence (Firestore)

ستتم إزالة هذه الوظيفة في إصدار رئيسي في المستقبل. بدلاً من ذلك ، قم بتعيين FirestoreSettings.localCache على مثيل من PersistentLocalCache لتشغيل ذاكرة التخزين المؤقت INSTINGEDDB. استدعاء هذه الوظيفة عند تحديد FirestoreSettings.localCache بالفعل ، سوف يلقي استثناء.

محاولات لتمكين التخزين المستمر متعددة الطابقين ، إن أمكن. إذا تم تمكينها في جميع علامات التبويب ، فإن جميع العمليات تشترك في الوصول إلى الثبات المحلي ، بما في ذلك التنفيذ المشترك للاستعلامات وتحديثات المستندات المحلية المعدلة في جميع الحالات المتصلة.

عند الفشل ، سوف يرفض enableMultiTabIndexedDbPersistence() الوعد أو يرمي استثناء. هناك العديد من الأسباب التي تجعل ذلك قد يفشل ، والتي يمكن تحديدها بواسطة code على الخطأ.

* الفشل في الإجراء: التطبيق مفتوح بالفعل في علامة تبويب متصفح أخرى ولا يتم تمكين TAB المتعدد. * غير مفيدة: المستعرض لا يتوافق مع تنفيذ الثبات في وضع عدم الاتصال.

لاحظ أنه حتى بعد الفشل ، ستبقى مثيل Firestore قابلاً للاستخدام ، ولكن سيتم تعطيل الثبات غير المتصلة بالإنترنت.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثال Firestore لتمكين الثبات ل.

عائدات:

وعد <doud>

Promise الذي يمثل بنجاح تمكين التخزين المستمر.

enablenetwork (Firestore)

إعادة تخصيص استخدام الشبكة لمثيل Firestore هذا بعد مكالمة سابقة لتعطيل العمل () .

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور

عائدات:

وعد <doud>

Promise يتم حله بمجرد تمكين الشبكة.

getPersistraftCacheIndexManager (Firestore)

إرجاع مدير فهرس PersistentCache المستخدم من قبل كائن Firestore المعطى.

مثيل PersistentCacheIndexManager ، أو null إذا لم يكن التخزين المستمر المحلي قيد الاستخدام.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور

عائدات:

perfectCacheIndexManager | باطل

LoadBundle (Firestore ، Bundledata)

يحمل حزمة Firestore في ذاكرة التخزين المؤقت المحلية.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore لتحميل حزم ل.
bundledata Readablestream <Uint8Array> | ArrayBuffer | خيط كائن يمثل الحزمة المراد تحميلها. الكائنات الصالحة هي ArrayBuffer ، ReadableStream<Uint8Array> أو string .

عائدات:

loadBundletask

كائن LoadBundleTask ، الذي يخطر المتصلين مع تحديثات التقدم ، وأحداث الإكمال أو الخطأ. يمكن استخدامه Promise<LoadBundleTaskProgress> .

اسمه اسمه (فايرستور ، الاسم)

يقرأ استعلام Firestore من ذاكرة التخزين المؤقت المحلية ، التي تم تحديدها بالاسم المحدد.

يتم تعبئة الاستعلامات المسماة في حزم على جانب الخادم (جنبا إلى جنب مع المستندات الناتجة) ، وتحميلها إلى ذاكرة التخزين المؤقت المحلية باستخدام loadBundle . مرة واحدة في ذاكرة التخزين المؤقت المحلية ، استخدم هذه الطريقة لاستخراج استعلام بالاسم.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore لقراءة الاستعلام من.
اسم خيط اسم الاستعلام.

عائدات:

وعد < Query | فارغ>

Promise يتم حله مع الاستعلام أو null .

onsnapshotsinsync (Firestore ، Observer)

يرفع مستمع لحدث لقطات في المزامنة. يشير حدث Snapshots-in-Sync إلى أن جميع المستمعين المتأثرين بتغيير معين قد أطلقوا النار ، حتى لو كان تغييرًا واحدًا تم إنشاؤه بواسطة الخادم يؤثر على مستمعين متعددين.

ملاحظة: يشير حدث Snapshots-in-Sync فقط إلى أن المستمعين متزامنين مع بعضهم البعض ، ولكن لا يرتبط بما إذا كانت هذه اللقطات متزامنة مع الخادم. استخدم Snapshotmetadata في المستمعين الفرديين لتحديد ما إذا كانت لقطة من ذاكرة التخزين المؤقت أو الخادم.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore لمزامنة اللقطات.
مراقب {التالي؟: (القيمة: void) => void ؛ خطأ؟: (خطأ: firestoreerror ) => باطلة ؛ كاملة؟: () => void ؛ } كائن واحد يحتوي على عمليات الاسترجاعات next error .

عائدات:

إلغاء الاشتراك

وظيفة إلغاء الاشتراك التي يمكن استدعاؤها لإلغاء مستمع اللقطة.

onsnapshotsinsync (Firestore ، onsync)

يرفع مستمع لحدث لقطات في المزامنة. يشير حدث Snapshots-in-Sync إلى أن جميع المستمعين المتأثرين بتغيير معين قد أطلقوا النار ، حتى لو كان تغييرًا واحدًا تم إنشاؤه بواسطة الخادم يؤثر على مستمعين متعددين.

ملاحظة: يشير حدث Snapshots-in-Sync فقط إلى أن المستمعين متزامنين مع بعضهم البعض ، ولكن لا يرتبط بما إذا كانت هذه اللقطات متزامنة مع الخادم. استخدم SnapshotMetadata في المستمعين الفرديين لتحديد ما إذا كانت لقطة من ذاكرة التخزين المؤقت أو الخادم.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore لمزامنة اللقطات.
onsync () => باطل رد الاتصال الذي يتم استدعاؤه في كل مرة يكون فيها جميع مستمعي اللقطات متزامنة مع بعضهم البعض.

عائدات:

إلغاء الاشتراك

وظيفة إلغاء الاشتراك التي يمكن استدعاؤها لإلغاء مستمع اللقطة.

RunTransaction (Firestore ، UpdateFunction ، Options)

ينفذ updateFunction المحدد ثم يحاول ارتكاب التغييرات المطبقة في المعاملة. إذا تغيرت أي مستند في المعاملة ، فإن Cloud updateFunction . إذا فشلت في الالتزام بعد 5 محاولات ، فإن المعاملة تفشل.

الحد الأقصى لعدد الكتابة المسموح به في معاملة واحدة هو 500.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور إشارة إلى قاعدة بيانات Firestore لتشغيل هذه المعاملة ضد.
updatefunction (المعاملة: المعاملة ) => الوعد <T> الوظيفة للتنفيذ في سياق المعاملة.
خيارات المعاملات كائن خيارات لتكوين أقصى عدد من المحاولات للالتزام.

عائدات:

الوعد <T>

إذا أكملت المعاملة بنجاح أو تم إحباطها بشكل صريح (أعاد updateFunction وعدًا فاشلاً) ، فإن الوعد الذي تم إرجاعه بواسطة updateFunction عاد هنا. خلاف ذلك ، إذا فشلت المعاملة ، يتم إرجاع الوعد المرفوض مع خطأ الفشل المقابل.

setIndexConfiguration (Firestore ، التكوين)

يتم توفير واجهة برمجة التطبيقات هذه كمعاينة للمطورين وقد تتغير بناءً على التعليقات التي نتلقاها. لا تستخدم واجهة برمجة التطبيقات هذه في بيئة الإنتاج.

بدلاً من إنشاء فهارس ذاكرة التخزين المؤقت يدويًا ، فكر في استخدام enablePersistentCacheIndexAutoCreation() للسماح لـ SDK بتحديد ما إذا كان سيتم إنشاء فهارس ذاكرة التخزين المؤقت للاستعلامات التي تعمل محليًا.

تكوين الفهرسة لتنفيذ الاستعلام المحلي. يتم تجاوز أي تكوين فهرس سابق. يحل Promise بمجرد استمرار تكوين الفهرس.

يتم إنشاء إدخالات الفهرس نفسها بشكل غير متزامن. يمكنك متابعة استخدام الاستعلامات التي تتطلب الفهرسة حتى لو لم تكن المؤشرات متوفرة بعد. سيبدأ تنفيذ الاستعلام تلقائيًا باستخدام الفهرس بمجرد كتابة إدخالات الفهرس.

يتم دعم الفهارس فقط مع ثبات الفهرسة. إذا لم يتم تمكين الفهرسة ، يتم تجاهل أي تكوين فهرس.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore لتكوين الفهارس ل.
إعدادات indexConfiguration تعريف الفهرس.

عائدات:

وعد <doud>

Promise يحل بمجرد تكوين جميع المؤشرات بنجاح.

الاستثناءات

FirestoreError إذا كان تنسيق JSON غير صالح.

setIndexConfiguration (Firestore ، JSON)

يتم توفير واجهة برمجة التطبيقات هذه كمعاينة للمطورين وقد تتغير بناءً على التعليقات التي نتلقاها. لا تستخدم واجهة برمجة التطبيقات هذه في بيئة الإنتاج.

بدلاً من إنشاء فهارس ذاكرة التخزين المؤقت يدويًا ، فكر في استخدام enablePersistentCacheIndexAutoCreation() للسماح لـ SDK بتحديد ما إذا كان سيتم إنشاء فهارس ذاكرة التخزين المؤقت للاستعلامات التي تعمل محليًا.

تكوين الفهرسة لتنفيذ الاستعلام المحلي. يتم تجاوز أي تكوين فهرس سابق. يحل Promise بمجرد استمرار تكوين الفهرس.

يتم إنشاء إدخالات الفهرس نفسها بشكل غير متزامن. يمكنك متابعة استخدام الاستعلامات التي تتطلب الفهرسة حتى لو لم تكن المؤشرات متوفرة بعد. سيبدأ تنفيذ الاستعلام تلقائيًا باستخدام الفهرس بمجرد كتابة إدخالات الفهرس.

يتم دعم الفهارس فقط مع ثبات الفهرسة. استدعاء إما enableIndexedDbPersistence() أو enableMultiTabIndexedDbPersistence() قبل تعيين تكوين فهرس. إذا لم يتم تمكين الفهرسة ، يتم تجاهل أي تكوين فهرس.

تقبل الطريقة تنسيق JSON الذي تم تصديره بواسطة Firebase CLI ( firebase firestore:indexes ). إذا كان تنسيق JSON غير صالح ، فإن هذه الطريقة ترمي خطأ.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور مثيل Firestore لتكوين الفهارس ل.
json خيط تنسيق JSON الذي تم تصديره بواسطة Firebase CLI.

عائدات:

وعد <doud>

Promise يحل بمجرد تكوين جميع المؤشرات بنجاح.

الاستثناءات

FirestoreError إذا كان تنسيق JSON غير صالح.

إنهاء (Firestore)

ينتهي مثيل Firestore المقدم.

بعد استدعاء terminate() فقط يمكن استخدام وظيفة clearIndexedDbPersistence() . أي وظيفة أخرى سوف ترمي FirestoreError .

لإعادة التشغيل بعد الإنهاء ، قم بإنشاء مثيل جديد لـ FirebaseFirestore مع getFirestore () .

لا يلغي الإنهاء أي كتابة معلقة ، ولن يتم حل أي وعود تنتظر استجابة من الخادم. إذا تم تمكين الثبات ، في المرة القادمة التي تبدأ فيها هذه الحالة ، ستستأنف إرسال هذه الكتابة إلى الخادم.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور

عائدات:

وعد <doud>

Promise يتم حله عند إنهاء المثيل بنجاح.

WaitforpendingWrites (Firestore)

يتم الاعتراف بالانتظار حتى يتم الاعتراف بالجميع المعلقة حاليًا للمستخدم النشط من قبل الواجهة الخلفية.

الوعد الذي تم إرجاعه يحل على الفور إذا لم تكن هناك كتابة معلقة. بخلاف ذلك ، ينتظر الوعد لجميع عمليات الكتابة التي تم إصدارها مسبقًا (بما في ذلك تلك المكتوبة في جلسة تطبيق سابقة) ، لكنها لا تنتظر الكتابة التي تمت إضافتها بعد استدعاء الوظيفة. إذا كنت تريد الانتظار حتى يتم كتابة كتاب إضافي ، فاتصل بـ waitForPendingWrites() مرة أخرى.

يتم رفض أي وعود متميزة waitForPendingWrites() أثناء تغييرات المستخدم.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور

عائدات:

وعد <doud>

Promise الذي يحل عندما تم الاعتراف بجميع عمليات الكتابة المعلقة حاليًا من قبل الواجهة الخلفية.

WriteBatch (Firestore)

ينشئ مجموعة الكتابة ، تستخدم لأداء عمليات كتابة متعددة كعملية ذرية واحدة. الحد الأقصى لعدد الكتابة المسموح بها في كتاب واحد هو 500.

على عكس المعاملات ، تستمر دفعات الكتابة في وضع عدم الاتصال ، وبالتالي فهي أفضل عندما لا تحتاج إلى شرط كتاباتك على بيانات القراءة.

إمضاء:

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

حدود

معامل يكتب وصف
فايرستور فايرستور

عائدات:

WriteBatch

مجموعة الكتابة التي يمكن استخدامها لتنفيذ العديد من الكتابة.

وظيفة()

عدد()

قم بإنشاء كائن AgegregateField يمكن استخدامه لحساب عدد المستندات في مجموعة النتائج من الاستعلام.

إمضاء:

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

عائدات:

إطعام <bumber>

Deletefield ()

إرجاع Sentinel للاستخدام مع updatedoc () أو setDOC () مع {merge: true} لوضع علامة على حقل للحذف.

إمضاء:

export declare function deleteField(): FieldValue;

عائدات:

قيمة الحقل

documentId ()

إرجاع FieldPath حارس خاص للإشارة إلى معرف المستند. يمكن استخدامه في الاستعلامات لفرز أو تصفية بواسطة معرف المستند.

إمضاء:

export declare function documentId(): FieldPath;

عائدات:

ميدان

getFirestore ()

إرجاع مثيل Firestore الافتراضي الموجود المرتبط بـ FirebaseApp الافتراضي . في حالة عدم وجود مثيل ، قم بتهيئة مثيل جديد بإعدادات افتراضية.

إمضاء:

export declare function getFirestore(): Firestore;

عائدات:

فايرستور

مثيل Firestore الافتراضي للتطبيق الافتراضي.

MemoryeAgerGarbageCollector ()

ينشئ مثيلًا MemoryEagerGarbageCollector . هذا هو أيضًا جامع القمامة الافتراضي ما لم يتم تحديده بشكل صريح على خلاف ذلك.

إمضاء:

export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector;

عائدات:

MemoryeAgerGarbageCollector

perfectmultipletabmanager ()

يخلق مثيلًا لـ PersistentMultipleTabManager .

إمضاء:

export declare function persistentMultipleTabManager(): PersistentMultipleTabManager;

عائدات:

perfectmultipletabmanager

servertimestamp ()

إرجاع Sentinel المستخدمة مع setDoc () أو updatedOC () لتضمين طابع زمني تم إنشاؤه بواسطة الخادم في البيانات المكتوبة.

إمضاء:

export declare function serverTimestamp(): FieldValue;

عائدات:

قيمة الحقل

وظيفة (databaseid ، ...)

getFirestore (databaseid)

يتم توفير واجهة برمجة التطبيقات هذه كمعاينة للمطورين وقد تتغير بناءً على التعليقات التي نتلقاها. لا تستخدم واجهة برمجة التطبيقات هذه في بيئة الإنتاج.

إرجاع مثيل Firestore الموجود المرتبط بـ FireBaseApp الافتراضي . في حالة عدم وجود مثيل ، قم بتهيئة مثيل جديد بإعدادات افتراضية.

إمضاء:

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

حدود

معامل يكتب وصف
DatabaseId خيط اسم قاعدة البيانات.

عائدات:

فايرستور

مثيل Firestore المسماة للتطبيق الافتراضي.

وظيفة (عناصر ، ...)

arrayremove (عناصر)

إرجاع قيمة خاصة يمكن استخدامها مع setDoc () أو تخبر الخادم بإزالة العناصر المعطاة من أي قيمة صفيف موجودة بالفعل على الخادم. ستتم إزالة جميع حالات كل عنصر محدد من الصفيف. إذا لم يكن الحقل الذي يتم تعديله بالفعل صفيفًا ، فسيتم كتابة صفيف فارغ.

إمضاء:

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

حدود

معامل يكتب وصف
عناصر مجهول[] العناصر لإزالتها من الصفيف.

عائدات:

قيمة الحقل

حارس FieldValue للاستخدام في مكالمة إلى setDoc() أو updateDoc()

Arrayunion (عناصر)

إرجاع قيمة خاصة يمكن استخدامها مع setDoc () أو updatedOC () التي تخبر الخادم باتحاد العناصر المعطاة مع أي قيمة صفيف موجودة بالفعل على الخادم. سيتم إضافة كل عنصر محدد غير موجود بالفعل في الصفيف إلى النهاية. 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;

حدود

معامل يكتب وصف
عناصر مجهول[] The elements to union into the array.

عائدات:

قيمة الحقل

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>;

حدود

معامل يكتب وصف
مجال سلسلة | 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>;

حدود

معامل يكتب وصف
مجال سلسلة | FieldPath Specifies the field to sum across the result set.

عائدات:

AggregateField <number>

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 سلسلة | 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 سلسلة | 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 مجهول[] 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 مجهول[] 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 مجهول[] 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 مجهول[] 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.

يتم تعطيل هذه الميزة بشكل افتراضي.

إمضاء:

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 <مجهول> Compare this AggregateField to the right .
يمين AggregateField <مجهول> 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;

حدود

معامل يكتب وصف
غادر وثيقة مرجعية <AppModelType, DbModelType> | CollectionReference <AppModelType, DbModelType> A reference to compare.
يمين وثيقة مرجعية <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;

حدود

معامل يكتب وصف
تسجيل مستوى تسجيل مستوى 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;

حدود

معامل يكتب وصف
ن رقم The value to increment by.

عائدات:

قيمة الحقل

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.
على التالي (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.
على التالي (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() ، حد() ).

عائدات:

استفسار <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() ، أو() ، او و() .

عائدات:

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() ، أو() ، او و() .

عائدات:

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 خيط[] 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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <AppModelType, DbModelType> A reference to a Firestore document.
طريق خيط A slash-separated path to a collection.
pathSegments خيط[] 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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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 خيط[] Additional path segments that will be applied relative to the first argument.

عائدات:

وثيقة مرجعية <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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <AppModelType, DbModelType> A reference to a Firestore document.
طريق خيط A slash-separated path to a document.
pathSegments خيط[] Additional path segments that will be applied relative to the first argument.

عائدات:

وثيقة مرجعية < 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>>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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>>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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>>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <AppModelType, DbModelType> A reference to the document to listen to.
على التالي (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;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <AppModelType, DbModelType> A reference to the document to listen to.
خيارات SnapshotListenOptions Options controlling the listen behavior.
على التالي (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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <AppModelType, DbModelType> A reference to the document to update.
بيانات تحديث البيانات <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>;

حدود

معامل يكتب وصف
مرجع وثيقة مرجعية <AppModelType, DbModelType> A reference to the document to update.
مجال سلسلة | FieldPath The first field to update.
قيمة مجهول The first value.
moreFieldsAndValues مجهول[] 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() ، يغلق عند مستوى() , 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;

تحديث البيانات

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);