add document to collection firestore code example

Example 1: firestore set a document

let data = {
  name: 'Los Angeles',
  state: 'CA',
  country: 'USA'
};

// Add a new document in collection "cities" with ID 'LA'
let setDoc = db.collection('cities').doc('LA').set(data);

Example 2: How to add document in firebase firestore

// Add a new document in collection "cities"db.collection("cities").doc("LA").set({    name: "Los Angeles",    state: "CA",    country: "USA"})db.collection('cities').doc('BJ').set({    capital: true}, { merge: true });

Example 3: firebase cloud method update

firebase deploy --only functions:functionNameHere