תיאור
הסרת שדות מהמסמכים שנוצרו בשלב הקודם.
המסמכים שנוצרו יכילו את כל השדות מהשלב הקודם, חוץ מהשדות שצוינו להסרה.
דוגמאות
Node.js
const results = await db.pipeline() .collection("cities") .removeFields("population", "location.state") .execute();
Web
const results = await execute(db.pipeline() .collection("cities") .removeFields("population", "location.state"));
Swift
let results = try await db.pipeline() .collection("cities") .removeFields(["population", "location.state"]) .execute()
Kotlin
val results = db.pipeline() .collection("cities") .removeFields("population", "location.state") .execute()
Java
Task<Pipeline.Snapshot> results = db.pipeline() .collection("cities") .removeFields("population", "location.state") .execute();
Python
results = ( client.pipeline() .collection("cities") .remove_fields("population", "location.state") .execute() )
Java
Pipeline.Snapshot results = firestore .pipeline() .collection("cities") .removeFields("population", "location.state") .execute() .get();
המשך
snapshot := client.Pipeline().Collection("cities"). RemoveFields(firestore.Fields("population", "location.state")). Execute(ctx)
התנהגות
הסרת שדות בתצוגת עץ
השלב remove_fields(...) מכבד את התחביר של השדה המקונן, ויסיר מפתחות ממפה.
לדוגמה, כדי להסיר את השדה המקונן state מקבוצת הנתונים:
Node.js
await db.collection("cities").doc("SF").set({name: "San Francisco", location: {country: "USA", state: "California"}});
await db.collection("cities").doc("TO").set({name: "Toronto", location: {country: "Canada", province: "Ontario"}});
אפשר להשתמש בצינור עיבוד הנתונים הבא:
Node.js
const results = await db.pipeline()
.collection("/cities")
.removeFields("location.state")
.execute();
המסמכים הבאים נוצרים:
{ name: "San Francisco", location: { country: "USA" } }
{ name: "Toronto", location: { country: "Canada", province: "Ontario" } }
אין תמיכה בהסרת רכיבים בתוך מערך.
הסרה בשדות שלא קיימים
אם שדה ברמה העליונה או שדה בתצוגת עץ שניתן ל-remove_fields(...) לא קיים במסמך, השלב לא יערוך את המסמך בשביל השדה הזה. שדות קיימים אחרים עדיין יוסרו.