firestore: delete data

Delete Data from Cloud Firestore

To delete a document, use the delete() method:

WEB
SWIFT
OBJECTIVE-C
ANDROID
JAVA
PYTHON
MORE
 
  
[[[ self . db collectionWithPath :@ "cities" ] documentWithPath :@ "DC" ]
    deleteDocumentWithCompletion
:^( NSError * _Nullable error ) {
     
if ( error != nil ) {
       
NSLog (@ "Error removing document: %@" , error );
     
} else {
       
NSLog (@ "Document successfully removed!" );
     
}
}];
 

Delete fields

To delete specific fields from a document, use the FieldValue.delete() method when you update a document:

WEB
SWIFT
OBJECTIVE-C
ANDROID
JAVA
PYTHON
MORE
 
  
[[[ self . db collectionWithPath :@ "cities" ] documentWithPath :@ "BJ" ] updateData :@{
 
@ "capital" : [ FIRFieldValue fieldValueForDelete ]
} completion :^( NSError * _Nullable error ) {
 
if ( error != nil ) {
   
NSLog (@ "Error updating document: %@" , error );
 
} else {
   
NSLog (@ "Document successfully updated" );
 
}
}];
 

Delete collections

To delete an entire collection or subcollection in Cloud Firestore, retrieve all the documents within the collection or subcollection and delete them. If you have larger collections, you may want to delete the documents in smaller batches to avoid out-of-memory errors. Repeat the process until you've deleted the entire collection or subcollection.

Deleting a collection requires coordinating an unbounded number of individual delete requests. If you need to delete entire collections, do so only from a trusted server environment. While it is possible to delete a collection from a mobile/web client, doing so has negative security and performance implications.

WEB
SWIFT
OBJECTIVE-C
ANDROID
JAVA
PYTHON
MORE
 
  
// Deleting collections from an iOS client is not recommended.
 

Delete data with the Firebase CLI

You can also use the Firebase CLI to delete documents and collections. Use the following command to delete data:

 
 
firebase firestore:delete [options] <<path>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值