Skip to content

Instantly share code, notes, and snippets.

@dmurawsky
Last active August 25, 2017 02:52
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 dmurawsky/5391b33ff8f5cdd2755b2cff927bb020 to your computer and use it in GitHub Desktop.
Save dmurawsky/5391b33ff8f5cdd2755b2cff927bb020 to your computer and use it in GitHub Desktop.
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)
exports.hourly = functions.https.onRequest((req, res) => {
const expiration = Date.now() + * 60 * 60 / 1000 // At least an hour old in seconds
const ref = admin.database().ref("space")
ref.orderByKey("timestamp").endAt(expiration).once("event", snap => {
const vals = snap.val()
Object.keys(vals).map(key => {
ref.child(key).remove()
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment