How to delete the array elements at index in firestore in javascript

后端 未结 3 1502
面向向阳花
面向向阳花 2021-01-26 14:54
    var arr = [ \"GKRLrcpSL2BmKx3BfvWj\",\"fMwH404fweoFJJqyE5Nf\" , \"DTurwbw64CWw4WosUQtC\" ] //
arr.forEach((element) => {
    console.log(element);
    db.collecti         


        
3条回答
  •  离开以前
    2021-01-26 15:28

    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.

提交回复
热议问题