Last active
December 6, 2016 04:28
-
-
Save DennisAlund/89de1c697e6a694acd84dfb4584bdb86 to your computer and use it in GitHub Desktop.
Gist for the article -- https://medium.com/evenbit/making-a-firebase-server-worker-in-the-cloud-c46c37cc88f3
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
| var visitsRef = firebase.database().ref('/visits'); | |
| visitsRef.on('child_added', function (snapshot) { | |
| var visitData = snapshot.val(); | |
| var visitId = snapshot.key; | |
| var updates = {}; | |
| updates[util.format('/meta-data/visits/%s', visitId)] = { | |
| created: firebase.database.ServerValue.TIMESTAMP, | |
| modified: firebase.database.ServerValue.TIMESTAMP | |
| }; | |
| updates[util.format('/businessVisits/%s/%s', visitData.businessId, visitId)] = visitData; | |
| updates[util.format('/memberVisits/%s/%s', visitData.memberId, visitId)] = visitData; | |
| firebase.database().ref().update(updates); | |
| }, function (errorObject) { | |
| util.error("The read failed: " + errorObject.code); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment