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.
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().
Any help would be appreciated!