Skip to content

Instantly share code, notes, and snippets.

@richartkeil
Created August 8, 2020 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richartkeil/1cd9733cf922f21f6ade1091f80e6285 to your computer and use it in GitHub Desktop.
Save richartkeil/1cd9733cf922f21f6ade1091f80e6285 to your computer and use it in GitHub Desktop.
const processUser = functions.firestore
.document("accounts/{accountId}/users/{userId}")
.onCreate(async (snapshot, context) => {
try {
await processTheUser(snapshot);
const event = new UserProcessed(snapshot);
await new Account(context.params.accountId).addEvent(event);
} catch (error) {
const event = new UserProcessingFailed(snapshot, error);
await new Account(context.params.accountId).addEvent(event);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment