How to use dynamic reference triggers in Cloud Functions for Firebase

Viewed 691

I would like to know how to change dynamically the reference of a Realtime Database trigger.

For example, I would like to add the current date at the beginning of the function (2017-07-17):

exports.makeUppercase = functions.database.ref('/2017-07-17/messages/{pushId}/original')
        .onWrite(event => {

But this date should not be coded statically. Instead, it should be the current date.

I am not sure if something like this can be done. The idea would be to use curly braces like the {pushId}, but somehow reference the date field:

exports.makeUppercase = functions.database.ref('/{currentDate}/messages/{pushId}/original')
        .onWrite(event => {

Thanks for your help.

1 Answers
Related