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.