Last active
June 12, 2018 00:42
-
-
Save nkmrh/0c7f374e68513ed5784718b7b756e79e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function wasTriggered(eventId: string) { | |
return firestore.runTransaction(async t => { | |
const ref = eventIdRef | |
const doc = await t.get(ref) | |
if (doc.exists) { | |
return true | |
} else { | |
t.set(ref, {}) | |
return false | |
} | |
}) | |
} | |
export const listener = functions.firestore.document(`path`).onCreate(async (snapshot, context) => { | |
if (await utils.wasTriggered(context.eventId)) { | |
console.log('Ignore: it has already been triggered') | |
return 0 | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment