Currently, I am facing an issue with deleting a 2 levels deep nested Reference in Firestore. Here is how my Schema is structured:
https://i.sstatic.net/INR0l.png
In terms of code, it appears as follows:
{
"folder": "bla",
"title": "myTitle",
"children": [
{
"ref": "firstReference"
},
{
"ref": "secondReference"
},
{
"title": "Subcollection Title",
"children": [
{
"ref": "thirdReference"
},
{
"ref": "forthReference"
}
]
}
]
}
My current challenge is figuring out how to remove the third or forth Reference from the second children array.
To remove an item from the first children array, I use this line of code:
docRef.update({children: firebase.firestore.FieldValue.arrayRemove(folder.children[index])
However, this solution only works for the top level.
Is there anyone familiar with handling the removal of deeper Nested elements?
I have attempted the following:
docRef.update({[`children[${index}].children`]: firebase.firestore.FieldValue.arrayRemove(
folder.children[index].children[secondIndex])});
Unfortunately, I encountered an Error stating that Paths must not contain '~', '*', '/', '[', or ']'
Thank you in advance for any assistance provided ;)