Skip to content

Instantly share code, notes, and snippets.

@vijayinyoutube
Created October 1, 2021 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijayinyoutube/872477731c163169fbcfd3d8f30852ec to your computer and use it in GitHub Desktop.
Save vijayinyoutube/872477731c163169fbcfd3d8f30852ec to your computer and use it in GitHub Desktop.
Future<void> addField() {
return collectionRef
.doc('MyDoc')
//will edit the doc if already available or will create a new doc with this given ID
.set(
{'role': "developer"},
SetOptions(merge: true),
// if set to 'false', then only these given fields will be added to that doc
)
.then((value) => debugPrint("User Added"))
.catchError((error) => debugPrint("Failed to add user: $error"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment