'Delete a nested array from firestore
i have a nested array (arrays inside an array) of frame numbers in which each frame number has its own data. I am not bothered about the frame number right now.
considering the array as [[0-100][100-200][200-300][300-400][400-500]] where [0-100] [100-200] is an array of frame numbers. If i want to delete the [100-200] array, what should I do?
Solution 1:[1]
Use
FieldValue.arrayRemoveto remove an element from an array by value. The elements can be of Type (*) as mentioned here. The value has to match the whole element in the array, and it will delete all elements in the array that match that value i.e.FieldValue.arrayRemove([100,....200]).Use
Array.splice. Iterate through each element in array(which is also an array) thenarray.splice(1,1)which means splicing the array at position 1 for [100-200] and delete count should be 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Priyashree Bhadra |
