Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Delete nested field in Firestore

$
0
0

I'm trying to delete a nested field in Firestore but I get FirebaseError: Function updateDoc() called with invalid data. deleteField() can only appear at the top level of your update data

So what I'm trying to delete is the individual fields (map) called bread, salt etc.

Picture of the firestore

const listRef = doc(db, "lists", list.id);const onDismiss = useCallback(async (id: string) => {    const onGoingIndex = onGoingItems.findIndex((item) => item.id === id);    let getName = onGoingItems.find((item) => item.id === id)?.name || "";    if (onGoingIndex !== -1) {      onGoingItems.splice(onGoingIndex, 1);    } else {      const doneIndex = doneItems.findIndex((item) => item.id === id);      getName = doneItems.find((item) => item.id === id)?.name || "";      doneItems.splice(doneIndex, 1);    }    await updateDoc(listRef, {      items: {        [getName]: deleteField(),      },    });  }, []);

I've also tried using FieldValue.delete() from firebase/firestore but it has no function called delete().Error on fieldvalue

Any help would be appreciated!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>