Showing only incomplete tasks

If we want to include a list view that displays only tasks that are not yet marked as complete, we'll need to modify our view to incorporate this change. The following snippet shows this modification. The action and view for the corresponding list page differ only in the name of the Couchbase view queried by the client (for example, all_incomplete and all):

//view named "all_incomplete" in the "tasks" design document
function(doc, meta) {
  if (doc.type == "task" && doc.isComplete === false) {
    emit(null, null);
  }
}

Notice that the check for incomplete status explicitly uses JavaScript's === operator. If you haven't used this operator, you should now know that it performs an explicit type check along with a value check. ...

Get Couchbase Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.