Created
July 30, 2017 15:11
-
-
Save barongun/04530380d7cd90d4ed9f858549495f05 to your computer and use it in GitHub Desktop.
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
const functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(functions.config().firebase); | |
exports.insertServerTime = functions.database.ref('/users/{deviceId}/tData/{key}').onWrite(event => { | |
const originalData = event.data | |
const serverTime = {time: event.timeStamp} | |
console.log('update key ->' + event.params.key) | |
return admin.database().ref('/users/'+event.params.deviceId+'/tData/' + event.params.key).push(serverTime) | |
//return event.data.ref.parent.push().set(serverTime) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment