what I basically want to do is this:
variable = \'whatever\';
fb.set({ variable : \"More Stuff\" });
So this will result in an entry that looks
For the latest version of Firebase, use brackets around the variable name:
firebase.database().ref("pathName").set({[variable] : 'MoreStuff'});
Using the other method of setting the index of the variable to the value will create an additional layer in the database structure.
You can create an Empty object
and set your variable as it's property and assign a value to it. Please see below:
let object: any = {};
object[variable] = value
Yes. The code is not working as expected because you are using object literal notation, which is the reason the it keeps the variable name as key, because that is how the notation works.
Solution
foo = {};
foo[variable] = 'more stuff';
fb.set(foo);