[Vuejs]-Updating boolean value with cloud firestore in Vue

0👍

I just noticed my error. The db has an object which has an id and a book object inside. I was calling the object.read, and this was undefined. I should have set it to object.book.read.

updateBook(object) {
  db.collection("books")
    .doc(object.id)
    .update({
      read: !object.book.read,
    })
    .then(() => {
      console.log("Book successfully updated!");
    })
    .catch((error) => {
      console.error("Error updating book: ", error);
    });
}

Leave a comment