title: Write data to document on creation
body: <p>I'm new to Firebase cloud function and I'm trying to write data down in a document every time a document is created, but the data is never written and I get no error in the console. Did I miss something? I'm using firestore.</p>
  
  <pre><code>exports.updateclient = functions.firestore
    .document('patients/{clientId}')
    .onCreate(async (snap, context) =&gt; {
      const database = admin.firestore();
      const settings = {timestampsInSnapshots: true};
      database.settings(settings);
      const clientId= context.params.clientId;
      const patientRef = database.collection('patient').doc(clientId);
      return patientRef.set({ id: clientId}, {merge: true});
    });
  </code></pre>