skip to Main Content

I’m new to web development, so I’m extremely sorry if the question is rife with inaccuracies.

My firestore database is composed like so:

enter image description here

Is there a way in which I could update bookname under a specific card (for instance card1)

Right now my approach is to use the following function:

enter image description here

But when I execute the IssueBook() function, I get an error shown on the console:

enter image description here

As far as I can see, the card1 field does have two fields within which can be updated so what does the console message imply?

Thank you in advance!

2

Answers


  1. It looks like you have a nested field under LibCard. To update a field in a nested object you can use dot notation:

    updateDoc(doc(db, "users", docid), {
        "LibCard.card1.bookname": "Coraline"
    });
    
    Login or Signup to reply.
  2. In my case category is an array this must me exact name of existing nested object in a document.

    const userData = doc(db, "users", userUid);
                await updateDoc(userData, {
                  category,
                });
    

    Console.log category array on React Native
    enter image description here

    Firebase document.
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search