on Firestore events - functions

functions.firestore
functions.firestore.document()

Validate the data sent by a user to the database. Make sure they don't send incorrect data. This helps to preserve data integrity.

exports.myFunction = functions.firestore
    .document("my-collection/{docId}")
    .onWrite((change, context) => {
        /* ... */
    })

on Storage events

functions.storage

the user uploads a file to Firebase Storage

perform data validation and transform

React to completed files uploads:

exports.generateThumbnail = functions.storage.object().onFinalize(async (object) => {
    const fileBucket = object.bucket
    // The Storage bucket that contains the file.
    const filePath = object.name
    // File path in the bucket.
    const contentType = object.contentType
    // File content type.
    const metageneration = object.metageneration
    // Number of times metadata has been generated. New objects have a value of 1.
})

Create a thumbnail for an uploaded image.

earlymorning logo

© 2025 - All rights reserved

on Firestore events - functions

functions.firestore
functions.firestore.document()

Validate the data sent by a user to the database. Make sure they don't send incorrect data. This helps to preserve data integrity.

exports.myFunction = functions.firestore
    .document("my-collection/{docId}")
    .onWrite((change, context) => {
        /* ... */
    })

on Storage events

functions.storage

the user uploads a file to Firebase Storage

perform data validation and transform

React to completed files uploads:

exports.generateThumbnail = functions.storage.object().onFinalize(async (object) => {
    const fileBucket = object.bucket
    // The Storage bucket that contains the file.
    const filePath = object.name
    // File path in the bucket.
    const contentType = object.contentType
    // File content type.
    const metageneration = object.metageneration
    // Number of times metadata has been generated. New objects have a value of 1.
})

Create a thumbnail for an uploaded image.