0 votes
in PouchDB by

Edit a todo using PouchdB

When the user checks a checkbox, the checkboxChanged function will be called, so we'll fill in the code to edit the object and call db.put:

function checkboxChanged(todo, event) {
  todo.completed = event.target.checked;
  db.put(todo);
}

This is similar to creating a document, however the document must also contain a _rev field (in addition to _id), otherwise the write will be rejected. This ensures that you dont accidently overwrite changes to a document.

You can test that this works by checking a todo item and refreshing the page. It should stay checked.

Related questions

0 votes
asked Jun 5, 2020 in PouchDB by AdilsonLima
0 votes
asked Jun 5, 2020 in PouchDB by AdilsonLima
...