Skip to content

Firebase Functions

Paul Yakovlev edited this page Feb 13, 2021 · 5 revisions

These functions let us keep the Algolia index up to date with the database. Any changes made to the database trigger one of the three functions, which performs the corresponding operation on the Algolia index. Since the reports are read from Algolia, not Firebase Database, we need to make sure the Algolia index is in sync with the database.

  • databaseOnCreate: Triggered when a new record is created in the database. Writes the new record to the Algolia index. Calls saveDocumentInAlgolia helper function.

  • databaseOnDelete: Triggered when a record is deleted from the database. Deletes that record from the Algolia index. Calls deleteDocumentFromAlgolia helper function.

  • databaseOnUpdate: Triggered when a record attribute is updated. Updates the record in the Algolia index. Calls updateDocumentInAlgolia helper function.

Clone this wiki locally