var arr = [ \"GKRLrcpSL2BmKx3BfvWj\",\"fMwH404fweoFJJqyE5Nf\" , \"DTurwbw64CWw4WosUQtC\" ] //
arr.forEach((element) => {
console.log(element);
db.collecti
If that works for you, use a map instead of an array, putting dummy values if necessary. Then you can remove the field directly.
fill: {
a: xxx,
b: xxx,
check: xxx
}
db.collection("Check").doc(element).update({
fill.check: firebase.firestore.FieldValue.delete()
})
My solution is based on specifying the item ID to remove, example:
firebase
.firestore()
.collection('projects') // Collection
.doc(project.id) // ID string
.delete() // Promise
FieldValue.arrayRemove()
only works with the complete value of the array item to remove. It won't work for removing items by index. In fact, Firestore doesn't offer any way to directly modify array items by index.
What you'll have to do instead is read the document, modify the "fill" array in memory as you see fit, then update the document with the new value back to the document.