Delete Field in Firestore Document

firestore get document field
firestore update document field
firestore remove from array
firebase delete all documents in collection
firestore delete map field
flutter firebase delete document
angular firestore delete document
firestore get document by id

how to delete a Document Field in Cloud Firestore? ... I'm using the code below but I can not.

this.db.doc(`ProfileUser/${userId}/followersCount/FollowersCount`).update({ 
[currentUserId]: firebase.firestore.FieldValue.delete()})

Anyone know how to do it?


You can try as shown below:

// get the reference to the doc
let docRef=this.db.doc(`ProfileUser/${userId}/followersCount/FollowersCount`);

// remove the {currentUserId} field from the document
let removeCurrentUserId = docRef.update({
    [currentUserId]: firebase.firestore.FieldValue.delete()
});

Delete data from Cloud Firestore, the documents in smaller batches to avoid out-of-memory errors. To delete specific fields from a document, use the FieldValue.delete() method when you update a document: Web var cityRef = db.collection('cities').doc('BJ'); // Remove the 'capital' field from the


Another solution that comes to my mind is, instead of focusing on updating the document deleting the field, update the entire document. Such as:

let data: Partial<ObjectType> = {
    //some fields here,
    thatField: '',
    //some fields there
};
this.angularFirestore.collection('collection_name').doc<ObjectType>('id').set(data);

Also, instead of initializing that field you may simply not include it.

Delete Field in Firestore Document, In part 6 of the Firestore tutorial we will learn how to delete whole documents from our Duration: 4:24 Posted: Sep 17, 2018 Delete Field in Firestore Document. Ask Question Asked 2 years, 7 months ago. Active 12 days ago. Viewed 10k times 11. 3. how to delete a Document Field in Cloud


For some reason the selected answer (firebase.firestore.FieldValue.delete()) did not work for me. but this did:

Simply set that field to null and it will be deleted!

// get the reference to the doc
let docRef=this.db.doc(`ProfileUser/${userId}/followersCount/FollowersCount`);

// remove the {currentUserId} field from the document
let removeCurrentUserId = docRef.update({
    [currentUserId]: null
});

Part 6 - Delete Field & Document, If we want to delete a document and all the documents within its sub-collection, we must do so manually. Deleting Fields. For deleting a specific field from a  To delete specific fields from a document, use the FieldValue.delete() method when you update a document: Web var cityRef = db.collection('cities').doc('BJ'); // Remove the 'capital' field from the


Firebase Update and Delete in Firestore, from the array. If the field being modified is not already an array it will be overwritten with an empty array. The elements to remove from the array. Example. let documentRef = firestore.doc('col/doc'); documentRef.update( 'array', Firestore. With that we can use the `fieldValue` variable to get access to our firebase firestore document fields and delete them in an `update` operation call. // Create a document reference const fruitRef = db.collection('fruits').doc('fruit_document'); // Remove the 'fruit' field from the document const removeFruit = fruitRef.update({ apple: fieldValue.delete() });


FieldValue, Update A Document Data to Cloud Firestore one or more fields rather than replacing the whole  To delete a specific field in a document: Select the document to view its fields. Click the delete icon beside the field you want to delete.


Firebase Cloud Firestore, Update the timestamp field with the value from the server db.collection('objects').​doc('some-id').update({ timestamp: firebase.firestore. A Cheat Sheet for Firestore to manipulate data.. “[Firebase] Cloud Firestore — Add, Set, Update, Delete Get data” is published by Aaron Lu.