'Delete a field from Firestore, with a variable key

I want to delete field by dynamic variable I tried to put the variable in [] like this:

var removeCapital = cityRef.update({
    [variable]: firebase.firestore.FieldValue.delete()
});

but it didn't work. Any other solutions, please? I think the problem is from the structure of the key it is like '0.maze.1.1' because when I tried the same method with key 'test' it worked.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source