Firestore! How can I remove a map from array by javascript code?

Maisam Alatrach

I am trying to remove a map form an array in Firestore by using Javascript Could any one help me with that?

enter image description here

By the way I used those several methods but none of them are working at all.

First method:

imgRef.update({
        "images": firebase.firestore.FieldValue.arrayRemove({
            "caption":...,
            "id":...,
            "postID":...,
            "url":...,
            "userID":...
        })
    });

Second method:

imgRef.update({
        "images": firebase.firestore.FieldValue.arrayRemove(0)
    });

Thanks for all your help

Doug Stevenson

Your first code sample will only work if you provide all of the map fields, and the exact values of the fields that match the array item to remove. Anything different, and it does nothing. Since you don't show the values, there's nothing we can do to say what might be going wrong.

If you don't know all of the exact values, your only alternative is the read the document, modify the array in the snapshot by finding and removing the array element that should be removed, and writing the new array back to the document.

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

How can i remove nested or parent object from array in javascript

How can i update an object (map) in an array with swift in firestore database?

How can I remove a number of elements from a hash map?

How can I remove and count duplicates in an array of objects? - Javascript

How can I remove a class from a list with less code?

How can I remove an array from my redux store?

How can I remove all html tags from an array?

How can I remove a property from a javascript object?

JS how to remove elements from array when i use array as map

How can I execute JavaScript code from Python?

How can I getElementsByClassName from HTML and push them into a JavaScript Array? How can I then alert this array?

How can I refactor this code to remove duplication?

How can i save data from a .txt file to an array in JavaScript?

Using React state, how can I remove markers from a Google map before adding new ones?

How can I remove a subdict in array in pymongo?

How can i use map on FileList array?

How can I map a nested array in JS

How do I copy an array so I can remove elements from the copy in Chapel?

Material React Select Multiple: How i can remove from my array when i click in a selected element?

how can i remove an element in javascript?

How can I remove a value from my session array which is displayed within a table?

How can I reactively remove an object from an array which is passed as a prop so that it is reflected in the DOM?

How can I customize the map and remove the 'POI Layer'?

How can I remove data type information from my xml in MarkLogic Javascript?

How can I Map Object Array To Array With Identifier For Duplicate Values?

"How can I code a 2 dimension array input in Javascript such that it looks like this?"

How can I make a stream of parent/child objects from firestore

How can I get specific document data from firestore querysnapshot?

How can I map Result<(), E> into a numeric error code?

TOP lista

quentelabel

Arquivo