title: Firebase Cloud Firestore create entry or update if it already exists
body: <p>I have an issue of knowing when to add or update an entry to a Firebase Firestore database. </p>
  
  <p>Using <code>doc_ref.set</code> will add a document if it does not exist. It will also override all of a documents fields if it already exists and set is called. </p>
  
  <p>Using <code>doc_ref.update</code> will update fields of a document if the document exists. If the document does not exist, nothing happens. </p>
  
  <p>How do I add a new field to a document if the field does not currently exist, or update the field if it does exist? I could read the database and check if the field exists, and then use either <code>set</code> or <code>update</code>, but surely there is an easier way?</p>