Search code examples
google-cloud-firestorenodemailer

Is it possible to use Firestore and nodemailer to send an email dependent on document data validation content?


I would like to send an email using the .onCreate method but only on condition if a field in the document is equal to "public"

service cloud.firestore {
  match /databases/{database}/documents {
    // Allow the user to read data if the document has the 'visibility'
    // field set to 'public'
    match /cities/{city} {
      allow read: if resource.data.visibility == 'public';
    }
  }
}

How is this incorporated with the sendMail function.

exports.sendMail = functions.firestore.document('Companys/{companyid}/Post-Operation/{postoperationid}').onCreate((snap, context) => {

Solution

  • According to the official documentation you can use

    Trigger Email

    to composes and sends an email based on the contents of a document written to a specified Cloud Firestore collection.

    Please consider that to install and use Firebase extensions, your project must be on the Blaze plan