Course lesson

Add a New Document to a Collection in Firestore from Angular with Firestore addDoc

We have a new task form but currently it doesn't do anything. In this lesson we'll implement the save button that will add the task to Firebase.

Duration
4 min
Access
Included
Transcript
Retained from source evidence

We have a new task form but currently it doesn't do anything. In this lesson we'll implement the save button that will add the task to Firebase.

First, we'll create a reference to our tasks collection in Firestore, and then push a new document to that collection with the addDoc function Firestore provides us.

After the document is in the database, we'll use the updateDoc function to edit that document and add the document's ID as a property on the document.