Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Couchbase Essentials

You're reading from  Couchbase Essentials

Product type Book
Published in Feb 2015
Publisher
ISBN-13 9781784394493
Pages 170 pages
Edition 1st Edition
Languages

Listing tasks


In the preceding snippet, after the task is created, a redirect to an index page is performed. This page is a list page used to view tasks. Building a list page requires finding all our tasks that will require a slight change to our model:

public class Task
{
  public string Description { get; set; }
  public bool IsComplete { get; set; }
  public bool Type { get { return "task"; }
}

Recall our discussion from the previous chapters on the use of a type property on documents to provide a classification for related documents, much in the way a table does for relational databases. In our to-do application, to identify tasks, we'll add a type property (which is read-only). The property is set to the task string, which will ensure that all task documents are serialized with this type. With this addition, we're ready to write our list page, starting with a map function:

//view named "all" in a design doc "tasks"
function(doc, meta) {
  if (doc.type == "task") {
    emit(null, null)...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}