Adding data with wildcard at the beginning of the path

Viewed 33

I have this specific pattern in my realtime Database in Firebase.

For example:

the string user as a constant -> user ID as a variable -> notification as a constant string -> message ID as variable -> userName as a constant string

'/user/' + 1234567 + '/notification/'+ 121212 + '/userName/'
'/user/' + 3454234 + '/notification/'+ 121212 + '/userName/'
'/user/' + 0893464 + '/notification/'+ 232323 + '/userName/'

and I want to add some content but only to a few of these above.

var ref = db.ref('/user/' + userID + '/notification/'+ 121212 + '/userName/').set(nameUser);

On every path where the message ID is 121212 it should do the action above. How can I do this? With wildcards? The user ID is unkown/ always different.

The code should look like this:

'/user/' + wildcard + '/notification/'+ 121212 + '/userName/' -> posting here
'/user/' + wildcard + '/notification/'+ 121212 + '/userName/' -posting here
'/user/' + wildcard + '/notification/'+ 232323 + '/userName/'
0 Answers
Related