I'm new to working with databases and need some help with updating an array in my Firestore using arrayUnion(). This is a React Native project using Expo.
This is the function I'm using:
await updateDoc(doc(db, "Habits", (habitId)), {
completed: arrayUnion("hello")
})
This is a screenshot of my DB:
This is the error I'm getting in the console:
Uncaught (in promise) FirebaseError: No document to update: projects/habitful-c5e3c/databases/(default)/documents/Habits/3fG9PvcfyMLHGTU2XR6s
Collection and document names are always case-sensitive. In your code, you have "Habits" with a capital H, but your collection is "habits" with a lowercase H. That's why the error message says the document isn't found.
Just change your code to match your collection.