Once you have added FirebaseTS, you are set to go!
How to update an document in Firestore
Updating a document
path - is an string array that points to a document in Firestore. The first element will be the collection and the second element will be the document id. The array can only point to a document id or it will throw an error.
The first element of the array points to a collection and the second points to a document and the pattern repeats itself if more elements are added.
This will update the age property to 64. If the property do not exist, it will append the existing data.
How to use
1. Import the FirebaseTSFirestore class.
2. Declare and initialize a FirebaseTSFirestore object.
3. Call the update() method.
Here, we updated the document age property from "User1Document" in the "UserCollection" collection.
Handling code on complete or fail
Sometimes you may want to do something when you have successfully or unsuccessfully updated data for a document, like a notification message. You can add the optional parameters onComplete and onFail.
©2019 - 2024 Codeible. All rights reserved.