קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
התוסף Delete User Data (מחיקת נתוני משתמשים) (delete-user-data) מאפשר לכם למחוק את הנתונים של משתמש מסוים כשמוחקים אותו מפרויקט Firebase. אתם יכולים להגדיר את התוסף הזה כך שימחק נתוני משתמשים מכל אחד מהשירותים הבאים או מכולם: Cloud Firestore, Realtime Database או Cloud Storage. כל הפעלה של התוסף למחיקת נתונים משויכת למזהה המשתמש UserId.
התוסף הזה שימושי לשמירה על פרטיות המשתמשים ולעמידה בדרישות התאימות. עם זאת, השימוש בתוסף הזה לא מבטיח עמידה בתקנות של הממשלה ובתקנות של התעשייה.
התוסף הזה מוחק נתונים רק מ-Cloud Firestore, מ-Realtime Database ומ-Cloud Storage. אם אתם מאחסנים נתוני משתמשים במקומות אחרים, אתם צריכים למחוק את נתוני המשתמשים גם מהמקורות האלה כשאתם מוחקים משתמשים.
התקנת התוסף
כדי להתקין את התוסף, פועלים לפי השלבים בדף Install Firebase Extension (התקנת תוסף של Firebase). לסיכום, מבצעים אחת מהפעולות הבאות:
במהלך ההתקנה של התוסף, תתבקשו לציין מספר פרמטרים של הגדרה:
המיקום של Cloud Functions:
בוחרים את המיקום שבו רוצים לפרוס את הפונקציות שנוצרו עבור התוסף הזה. בדרך כלל כדאי לבחור מיקום שקרוב למסד הנתונים. לקבלת עזרה בבחירת מיקום, אפשר לעיין במדריך לבחירת מיקום.
נתיבי Cloud Firestore:
אילו נתיבים במופע Cloud Firestore מכילים נתוני משתמשים? אם אתם לא משתמשים ב-Cloud Firestore, משאירים את השדה ריק. מזינים את הנתיבים המלאים, מופרדים בפסיקים. אפשר לייצג את מזהה המשתמש של המשתמש שנמחק באמצעות {UID}. לדוגמה, אם יש לכם את האוספים users ו-admins, ובכל אוסף יש מסמכים עם מזהה המשתמש כמזהה המסמך, תוכלו להזין users/{UID},admins/{UID}.
מצב מחיקה של Cloud Firestore:
(רלוונטי רק אם משתמשים בפרמטר Cloud Firestore paths). איך רוצים למחוק מסמכים ב-Cloud Firestore? כדי למחוק גם מסמכים באוספי משנה, מגדירים את הפרמטר הזה לערך recursive.
מופע של מסד נתונים בזמן אמת:
מאיזה מופע של Realtime Database רוצים למחוק את נתוני המשתמש?
המיקום של Realtime Database:
(רלוונטי רק אם סיפקתם את הפרמטר Realtime Database instance). מאיזה מיקום ב-Realtime Database רוצים למחוק את נתוני המשתמש?
נתיבים במסד נתונים בזמן אמת:
אילו נתיבים במופע של Realtime Database מכילים נתוני משתמשים? אם אתם לא משתמשים ב-Realtime Database, משאירים את השדה ריק. מזינים את הנתיבים המלאים, מופרדים בפסיקים. אפשר לייצג את מזהה המשתמש של המשתמש שנמחק באמצעות {UID}. לדוגמה: users/{UID},admins/{UID}
נתיבים ב-Cloud Storage:
איפה ב-Google Cloud Storage מאוחסנים נתוני המשתמשים? אם אתם לא משתמשים ב-Cloud Storage, משאירים את השדה ריק. מזינים את הנתיבים המלאים לקבצים או לספריות בדלי Storage, כשהם מופרדים בפסיקים. משתמשים ב-{UID} כדי לייצג את מזהה המשתמש של המשתמש שנמחק, וב-{DEFAULT} כדי לייצג את דלי האחסון שמוגדר כברירת מחדל.
הנה כמה דוגמאות:
כדי למחוק את כל הקבצים בדלי ברירת המחדל עם סכימת שמות הקבצים {UID}-pic.png, מזינים {DEFAULT}/{UID}-pic.png.
כדי למחוק גם את כל הקבצים בקטגוריה אחרת בשם my-app-logs עם סכימת מתן השמות {UID}-logs.txt, מזינים {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt.
כדי גם למחוק ספרייה עם תווית של מזהה משתמש ואת כל הקבצים שלה (כמו media/{UID}), מזינים {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}.
גילוי נתונים למחיקה
התוסף הזה משתמש בכמה מנגנונים כדי לגלות נתונים למחיקה. צריך להגדיר את המנגנונים האלה באופן מפורש כדי שהתוסף ימחק נתונים. התוסף ימחק רק נתונים שהוגדרו במפורש למחיקה על סמך המנגנונים שסופקו.
חשוב לשים לב להבדלים הבאים בהתנהגות של כל שירות:
Cloud Firestore: התנהגות ברירת המחדל היא מחיקה שטחית של מסמך (אוספי משנה לא יימחקו). כדי למחוק באופן רקורסיבי את כל אוספי המשנה של מסמך, מגדירים את האפשרות Cloud Firestore delete mode (מצב מחיקה ב-Cloud Firestore) ל-Recursive (רקורסיבי).
Realtime Database: כל הנתונים בצומת שצוין יימחקו.
אחסון: אם מציינים נתיב של ספרייה, כל הקבצים ותיקיות המשנה יימחקו.
לפי נתיב
כשמגדירים את הנתיבים של Cloud Firestore, Realtime Database ו-Cloud Storage, אפשר להגדיר משתנה UID בנתיבים שיוחלף ב-UID של המשתמש המאומת. כשמשתמש נמחק, התוסף מוחק את כל הנתונים שמשויכים למזהה המשתמש הזה בנתיבים שצוינו, למשל:
כדי שהתוסף יזהה באופן אוטומטי מסמכי Firestore למחיקה, צריך להגדיר את פרמטר ההגדרה Enable auto discovery (הפעלת זיהוי אוטומטי) לערך Yes (כן).
התכונה 'גילוי אוטומטי' פועלת על ידי מעבר אוטומטי במסד הנתונים כדי למצוא אוספים ומסמכים שצריך למחוק בהתאם להגדרות. התוסף מזהה את האוספים והמסמכים האלה באמצעות המתודולוגיה הבאה:
קודם כל, התוסף מוצא את כל אוספי הבסיס במסד הנתונים. אם מזהה האוסף תואם למזהה המשתמש (UID), האוסף כולו נמחק (המחיקה היא רקורסיבית או שטחית, בהתאם להגדרת התוסף של 'מצב מחיקה ב-Cloud Firestore').
שנית, אם מזהה האוסף לא תואם, התוסף ינסה לזהות ולמחוק מסמך אם מזהה המסמך שלו תואם ל-UID של המשתמש.
לבסוף, לכל מסמך:
א. אם עומק החיפוש הנוכחי (ראו בהמשך) קטן מעומק החיפוש שהוגדר או שווה לו, התהליך יחזור על עצמו עבור כל אוספי המשנה של המסמך הנוכחי.
ב. אם הוגדרו שדות חיפוש, התוסף יבדוק אם השדות שסופקו תואמים למזהה המשתמש (UID). אם נמצאת התאמה, המסמך יימחק.
עומק החיפוש
התוסף מציע ערך של עומק החיפוש שניתן להגדרה (ברירת המחדל היא 3). המעבר יתבצע רק אם עומק החיפוש הנוכחי קטן מעומק החיפוש שהוגדר או שווה לו. עומק החיפוש הנוכחי מבוסס על העומק של האוסף הנוכחי או של אוסף האב של המסמכים, לדוגמה
התוסף הזה לא ימחק אוטומטית מזהי משתמשים ששמורים במערכים או במפות, והוא לא יחפש נתונים עם מפתח לפי מזהה משתמש ששמורים באוספי משנה עם קינון עמוק מעבר לעומק שצוין למעלה.
[[["התוכן קל להבנה","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-07-25 (שעון UTC)."],[],[],null,["\u003cbr /\u003e\n\nThe Delete User Data extension (`delete-user-data`) lets you delete a user's data when the user is deleted from your Firebase project. You can configure this extension to delete user data from any or all of the following: Cloud Firestore, Realtime Database, or Cloud Storage. Each trigger of the extension to delete data is keyed to the user's `UserId`.\n| **Note:** To use this extension, you need to manage your users with Firebase Authentication.\n\nThis extension is useful for respecting user privacy and fulfilling compliance requirements. However, using this extension does not guarantee compliance with government and industry regulations.\n\nPrerequisites\n\n- You must use [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.\n\n- This extension only deletes data from [Cloud Firestore](https://firebase.google.com/docs/firestore), [Realtime Database](https://firebase.google.com/docs/database), and [Cloud Storage](https://firebase.google.com/docs/storage). If you store user data elsewhere, you should also delete user data from those sources when you delete users.\n\nInstall the extension\n\nTo install the extension, follow the steps on the [Install Firebase Extension](https://firebase.google.com/docs/extensions/install-extensions) page. In summary, do one of the following:\n\n- **Firebase console:** Click the following button:\n\n [Install the Delete User Data extension](https://console.firebase.google.com/project/_/extensions/install?ref=firebase%2Fdelete-user-data)\n- **CLI:** Run the following command:\n\n firebase ext:install firebase/delete-user-data --project=\u003cvar translate=\"no\"\u003eprojectId-or-alias\u003c/var\u003e\n\nDuring the installation of the extension, you will be prompted to specify a number of configuration parameters:\n\n- **Cloud Functions location:**\n\n Select the location of where you want to deploy the functions created for this extension. You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).\n- **Cloud Firestore paths:**\n\n Which paths in your Cloud Firestore instance contain user data? Leave empty if you don't use Cloud Firestore. Enter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. For example, if you have the collections `users` and `admins`, and each collection has documents with the User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.\n- **Cloud Firestore delete mode:**\n\n (Only applicable if you use the `Cloud Firestore paths` parameter.) How do you want to delete Cloud Firestore documents? To also delete documents in subcollections, set this parameter to `recursive`.\n- **Realtime Database instance:**\n\n From which Realtime Database instance do you want to delete user data?\n- **Realtime Database location:**\n\n (Only applicable if you provided the `Realtime Database instance` parameter.) From which Realtime Database location do you want to delete user data?\n- **Realtime Database paths:**\n\n Which paths in your Realtime Database instance contain user data? Leave empty if you don't use Realtime Database. Enter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. For example: `users/{UID},admins/{UID}`.\n- **Cloud Storage paths:**\n\n Where in Google Cloud Storage do you store user data? Leave empty if you don't use Cloud Storage. Enter the full paths to files or directories in your Storage buckets, separated by commas. Use `{UID}` to represent the User ID of the deleted user, and use `{DEFAULT}` to represent your default Storage bucket.\n\n Here's a series of examples:\n - To delete all the files in your default bucket with the file naming scheme `{UID}-pic.png`, enter `{DEFAULT}/{UID}-pic.png`.\n - To also delete all the files in another bucket called `my-app-logs` with the file naming scheme `{UID}-logs.txt`, enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt`.\n - To *also* delete a User ID-labeled directory and all its files (like `media/{UID}`), enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}`.\n\nDiscovering data for deletion\n\nThere are a few mechanisms that this extension uses to discover data for deletion. These mechanisms have to be explicitly configured for the extension to delete data. The extension will only delete data that is explicitly configured to delete based on the mechanisms provided.\n\nBe aware of the following behavioral differences between each service:\n\n- Cloud Firestore: the default behavior is to shallow delete a document (sub-collections will not be deleted). To recursively delete all sub-collections of a document, set the \"Cloud Firestore delete mode\" option to \"Recursive\".\n- Realtime Database: all data at the specified node will be deleted.\n- Storage: if a directory path is specified, all files and sub-directories will be deleted.\n\nBy path\n\nWhen configuring the Cloud Firestore, Realtime Database \\& Cloud Storage paths, it's possible to define a `UID` variable in the paths which will be replaced with the authenticated user's UID. When a user is deleted, the extension will delete all data keyed on that UID at the given paths, for example:\n\n- Cloud Firestore path(s): `users/{UID},admins/{UID}`\n- Realtime Database path(s): `likes/{UID}`\n- Cloud Storage path(s): `{DEFAULT}/uploads/{UID},{DEFAULT}/avatars/{UID}.jpeg`\n\nAuto Discovery (Cloud Firestore)\n\nTo enable the extension to automatically discover Firestore documents to delete, set the \"Enable auto discovery\" configuration parameter to \"Yes\".\n\nAuto-discovery works by automatically traversing the database to find collections and documents which should be deleted according to your configuration. The extension identifies those collections and documents with the following methodology:\n\n1. First, the extension finds all root collections in the database. If a collection's ID matches that of the user's UID, the entire collection is deleted (deletion is either recursive or shallow, depending on the extensions's configuration for \"Cloud Firestore delete mode\").\n2. Secondly, if the collection ID does not match, the extension will attempt to identify and delete a document if its document ID matches that of the user's UID.\n3. Finally, for each document: a. If the current search depth (see below) is less than or equal to the configured search depth, the process will be repeated for all of the current document's sub-collections. b. If search fields have been configured, the extension will check if the provided fields match the user's UID. If a match is found, the document will be deleted.\n\nSearch Depth\n\nThe extension offers a configurable search depth value (defaulting to 3). Traversal will only be executed if the current search depth is less than or equal to the configured search depth. The current search depth is based on the depth of the current collection or documents parent collection, for example \n\n /users = 1\n /users/\u003cdocument-id\u003e = 1\n /users/\u003cdocument-id\u003e/comments = 2\n /users/\u003cdocument-id\u003e/comments/\u003cdocument-id\u003e = 2\n\nThis extension will NOT automatically delete UIDs stored in arrays or maps, and it will not search for data keyed by user ID stored in deeply nested subcollections past the depth specified above.\n| **Note:** with large databases, traversal-based discovery may incur many reads and deletions since it reads all documents in the corresponding collections. Please be aware of Cloud Firestore billing prices and how this might impact you. Auto discovery is completely optional."]]