Skip to Main Content
CouchDB: The Definitive Guide
book

CouchDB: The Definitive Guide

by J. Chris Anderson, Jan Lehnardt, Noah Slater
January 2010
Intermediate to advanced content levelIntermediate to advanced
272 pages
6h 41m
English
O'Reilly Media, Inc.
Content preview from CouchDB: The Definitive Guide

Chapter 5. Design Documents

Design documents are a special type of CouchDB document that contains application code. Because it runs inside a database, the application API is highly structured. We’ve seen JavaScript views and other functions in the previous chapters. In this section, we’ll take a look at the function APIs, and talk about how functions in a design document are related within applications.

This part (Part II, Chapters Chapter 5 through Chapter 9) lays the foundation for Part III, where we take what we’ve learned and build a small blog application to further develop an understanding of how CouchDB applications are built. The application is called Sofa, and on a few occasions we discuss it this part. If you are unclear on what we are referring to, do not worry, we’ll get to it in Part III.

Document Modeling

In our experience, there are two main kinds of documents. The first kind is like something a word processor would save, or a user profile. With that sort of data, you want to denormalize as much as you possibly can. Basically, you want to be able to load the document in one request and get something that makes sense enough to display.

A technique exists for creating “virtual” documents by using views to collate data together. You could use this to store each attribute of your user profiles in a different document, but I wouldn’t recommend it. Virtual documents are useful in cases where the presented view will be created by merging the work of different authors; for instance, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Getting Started with CouchDB

Getting Started with CouchDB

MC Brown
Scaling CouchDB

Scaling CouchDB

Bradley Holt
Cloud Native Go

Cloud Native Go

Matthew A. Titmus

Publisher Resources

ISBN: 9780596158156Errata Page