How to set/update arrays inside objects in Firebase/Vue.js
Im here to save your life. You will learn how to set or update an array inside and object inside ANOTHER object in Firebase.
In one of my Firebase/Vue.js projects, i needed to update a document with a complex structure. Something like this:
As we know, if we want to just update “profile”, we only need to do this:
But if we have to set/update a path like this:
How we can do that? It’s very simple
And pushing to an array:
This is how Firebase knows that this is a path.
Plus, we can pass dynamic paths, so the code can be reutilized:
It’s important to use `` instead of “” or ‘’, and don’t forget the square brackets! .
If you found this post useful, please consider buying me a coffe !