Firebase V9 Firestore UPDATE Document Data Using updateDoc()

Raja Tamil
3 min readAug 8, 2022

There are two methods you can use to update an existing document in Firebase Version 9 Cloud Firestore.

setDoc()
updateDoc() you’re here

Using updateDoc(), you can only update the document field of an existing document in the Firestore Database which can be:

Add A New Document Field Using updateDoc()

Here is a sample document inside the cities collection from the Cloud Firestore Database.

In order to update an existing document using the updateDoc()method, we need three methods:

  • getDatabase() → where we want to update a document.
  • doc() → where we’ll be passing references of database, collection, and ID of a document that we want to update one of its fields.
  • updateDoc() → where we actually pass new data that we want to replace along with the doc() method.

--

--

Raja Tamil
Raja Tamil

Written by Raja Tamil

👇click the link and get 80% OFF on the premium web development courses (HTML5, CSS3, JavaScript ES6, Vue JS 3 & Firebase 10 https://softauthor.com