mission-completed
Note: Trigger events are delivered at least once, which means that rarely, spurious duplicates may occur. https://cloud.google.com/functions/docs/concepts/events-triggers#triggers
Cloud Functions rarely fire multiple times. If multiple payment occurs, it is a big problem!!
mission-completed uses transactions to prevent multiple trigger events.
If you try to set the completed flag to true many times, CompletedError will be returned.
await Mission.markCompletedref, id // first: successawait Mission.markCompletedref, id // second: throw CompletedError
Results are saved like this.

Install
yarn install mission-completed
Usage
This sample is written in TypeScript.
1. Initialize
Initialize event-response in your index.ts.
Mission.initializefunctions.config.firebase
2. mark completed in Cloud Functions
If mission has already been completed, throw CompletedError in Mission.markCompleted(event.data.ref, 'updateUser')
.
exports.updateUser = functions.firestore.document'users/{userId}' .onCreate
This will continue the initial process, but the simultaneous firing process will stop with CompletedError.
License
MIT