קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Firestore הוא פתרון טוב של מסד נתונים שניתן להרחבה, שמאפשר לשמור על סנכרון הנתונים בין לקוחות אינטרנט.
להרבה אפליקציות, התמיכה המנוהלת של Firestore באפליקציות אופליין חשובה במיוחד, כי היא מאפשרת לכם ליצור אפליקציות רספונסיביות שפועלות ללא קשר לזמן האחזור ברשת או לחיבור לאינטרנט. אבל ערכות SDK עשירות בתכונות הן גדולות יותר. מה
מציעה Firebase לאפליקציות שצריכות רק להשתמש בפעולות בסיסיות של יצירה, קריאה, עדכון
ומחיקה, ולא צריכות תמיכה מנוהלת במצב אופליין?
הפתרון: Firestore Lite
Firestore Lite הוא SDK קל משקל ועצמאי של Firestore שמבוסס על REST בלבד. הוא תומך באחזור של מסמך יחיד, בהרצת שאילתות ובעדכונים של מסמכים, וגודלו קטן בהרבה מגודל ה-SDK הרגיל לאינטרנט. ב-Firestore Lite אין פיצוי על השהיה,
שמירה במטמון במצב אופליין, המשך שאילתה ומאזיני תמונות מצב, אבל בתרחישי שימוש מסוימים, הקיזוז בין גודל הספרייה לבין זמן ההפעלה הוא משתלם.
ייבוא של Firestore Lite
Firestore Lite זמין דרך npm כחלק מה-SDK המודולרי. לכן הוא מודולרי לחלוטין וניתן להסרה של קוד שלא בשימוש (tree-shaking).
כדי להקטין את הגודל ולשפר את המהירות, ב-Firestore Lite לא נכללות התכונות הבאות מ-Firestore SDK הרגיל:
גורמים מטפלים באירועים של DocumentSnapshot. השיטה onSnapshot והאובייקטים DocumentChange, SnapshotListenerOptions, SnapshotMetadata, SnapshotOptions ו-Unsubscribe לא נכללים.
כלי עזר לשימור. השיטות enableIndexedDBPersistence, enableMultiTabIndexedDbPersistence ו-clearIndexedDbPersistence לא נכללות.
חבילות Firestore. השיטה loadBundle והשיטות שקשורות אליה, והאובייקטים LoadBundleTask ו-LoadBundleTaskProgress לא נכללים.
הטמעה של שליפות, שאילתות ועדכונים של מסמכים
אחרי שמייבאים את Firestore Lite, אפשר לבצע את כל הקריאות המוכרות ל-API לקבלת נתונים ולעדכון נתונים. כל התרחישים לדוגמה של הוספת נתונים וקבלת נתונים רלוונטיים.
יכול להיות שיהיה לכם קשה להחליט מתי להפסיק להשתמש בתכונות של שמירת נתונים במצב אופליין ובשמירת נתונים במטמון ב-Firestore SDK הרגיל. חשוב להבין את התכונות האלה לפני שמחליטים לוותר עליהן לטובת התקורה הנמוכה יותר של Firestore Lite. באופן כללי, כדאי לשקול את הגורמים הבאים כשמחליטים אם להשתמש ב-Firestore Lite:
סטטוס אונליין – Firestore Lite מתאים לאפליקציות שלא צריכות עדכונים בזמן אמת ושיש להן קישוריות.
מגבלות גודל – Firestore Lite הוא פתרון מצוין אם רוצים לצמצם את הגודל הכולל של חבילת ה-JavaScript.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-09-05 (שעון UTC)."],[],[],null,["\u003cbr /\u003e\n\nFirestore is a good scalable database solution to keep data in sync across Web\nclients.\n\nFor many apps, Firestore's managed offline support is especially important,\nletting you build responsive apps that work regardless of network latency or\nInternet connectivity. But feature-rich SDKs come at a size cost. What\ndoes Firebase offer for apps that only need to use basic create, read, update\nand delete operations, and don't need managed offline support?\n| **Note:** Before using Firestore Lite, be sure you understand the standard Firestore Web API and Firestore's offline capabilities as part of the full [feature set](../index.html). We recommend Firestore Lite for developers who have experience building with Firestore and can evaluate the tradeoffs of using a lightweight version.\n\nSolution: Firestore Lite\n\nFirestore Lite is a lightweight, standalone REST-only Firestore SDK that\nsupports single document fetches, query execution, and document updates, at a\nfraction of the regular Web SDK size. Firestore Lite omits latency compensation,\noffline caching, query resumption and snapshot listeners, but for particular\nuse cases, the reductions in library size and startup time make a great tradeoff.\n\nImport Firestore Lite\n\nFirestore Lite is available via npm as part of the\n[modular SDK](//firebase.google.com/docs/web/learn-more#modular-version). It is\nthus fully modular and tree-shakeable.\n\nThe following import style is supported. \n\n import { initializeApp } from \"firebase/app\";\n import {\n getFirestore,\n getDoc,\n updateDoc\n } from 'firebase/firestore/lite';\n\nAPI features not supported by Firestore Lite\n\nFor size and speed, Firestore Lite omits these features from the standard\nFirestore SDK:\n\n- **DocumentSnapshot event handlers** . The `onSnapshot` method and `DocumentChange`, `SnapshotListenerOptions`, `SnapshotMetadata`, `SnapshotOptions` and `Unsubscribe` objects are not included.\n- **Persistence helpers** . The `enableIndexedDBPersistence`, `enableMultiTabIndexedDbPersistence`, and `clearIndexedDbPersistence` methods are not included.\n- **Firestore bundles** . The `loadBundle` method and related methods, and the `LoadBundleTask` and `LoadBundleTaskProgress` objects are not included.\n\nImplement document fetches, queries and updates\n\nAfter importing Firestore Lite, you can make all of the familiar API get\nand update calls. The use cases for [adding data](../manage-data/add-data)\nand [getting data](../query-data/get-data) all apply. \n\n import {\n getFirestore,\n getDoc,\n updateDoc,\n doc\n } from '@firebase/firestore/lite';\n\n const firestore = getFirestore(app);\n const docRef = doc(firestore, 'collection/doc');\n const docSnap = await getDoc(docRef);\n await updateDoc(docRef, \"field\", 'value');\n\nWhen to use Firestore Lite\n\nIt can be tricky to decide when to let go of the standard Firestore SDK's\noffline persistence and caching features. You should understand these features\nbefore deciding to trade them away for the lower overhead of Firestore Lite. In\ngeneral, weigh these factors when deciding whether to use Firestore Lite:\n\n- **Online status** - Firestore Lite is good for apps that do not need live updates and have connectivity.\n- **Size constraints** - Firestore Lite is great if you want to reduce your overall JavaScript bundle size."]]