توضیحات
فیلدها را از اسناد تولید شده توسط مرحله قبل حذف کنید.
اسناد تولید شده شامل تمام فیلدهای مرحله قبل به جز فیلدهایی که برای حذف مشخص شدهاند، خواهد بود.
مثالها
نود جی اس
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"));
سویفت
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();
پایتون
results = ( client.pipeline() .collection("cities") .remove_fields("population", "location.state") .execute() )
جاوا
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 تو در تو از مجموعه داده:
نود جی اس
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"}});
میتوان از لوله زیر استفاده کرد:
نود جی اس
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(...) داده شده است در سندی وجود نداشته باشد، مرحله سند مربوط به آن فیلد را ویرایش نمیکند. سایر فیلدهای موجود همچنان حذف خواهند شد.