Created
June 26, 2019 08:24
-
-
Save e-lin/44dcdcddbd602594ab23b33678697e46 to your computer and use it in GitHub Desktop.
Firestore trigger 1 - send answer to Android Thing
This file contains hidden or 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 const onAnswer = functions.firestore.document('/pic/{picId}').onUpdate(_onAnswer) | |
async function _onAnswer(change: functions.Change<DocumentSnapshot>): Promise<any> { | |
const picId = change.before.id "//20180624120000" | |
const previous = change.before.data() as Pic | |
const pic = change.after.data() as Pic | |
// Only interested in pics that have a new answer | |
if (previous.answer || !pic.answer) { | |
console.log("This is not the update you are looking for.") | |
return Promise.resolve() | |
} | |
} | |
// cont'd... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment