shamsmosowi / git-bot

0 stars 0 forks source link

how to set a value of a string field in firestore #20

Open harinij opened 1 year ago

harinij commented 1 year ago

how to set a value of a string field in firestore

shamsmosowi commented 1 year ago

Hi,

You can use the Firestore’s set() method to set the value of a string field. The set() method takes two parameters, the first parameter is the data you want to set and the second parameter is an optional callback function that will be called when the data is set.

You can use the following code:

db.collection("myCollection").doc("myDocument").set({
  myStringField: "myStringValue"
}, function(error) {
  if (error) {
    console.log("Error setting data: ", error);
  } else {
    console.log("Data set successfully!");
  }
});

This code will set the value of the string field myStringField in the document myDocument in the collection myCollection to the value myStringValue.

I hope this helps!