Skip to content

Instantly share code, notes, and snippets.

@avivl
Created November 1, 2017 20:57
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 avivl/c16af302a09a338f41480a11689a10d9 to your computer and use it in GitHub Desktop.
Save avivl/c16af302a09a338f41480a11689a10d9 to your computer and use it in GitHub Desktop.
exports.DeleteRunningJobFromFinished = functions.database.ref('finished-jobs/{key}').onCreate(event =>
{
const runningRef = event.data.adminRef.root.child('running-jobs')
const jobId = event.data.val()['protoPayload']['serviceData']['jobCompletedEvent']['job']['jobName']['jobId']
runningRef.orderByChild('protoPayload/serviceData/jobInsertResponse/resource/jobName/jobId')
.equalTo(jobId).once("value", function (snapshot) {
snapshot.forEach(function (data) {
runningRef.child(data.key).remove()
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment