We've seen in Chapter 3, Getting Started with CouchDB and Futon, how CouchDB looks at user documents. In this chapter, we are going to learn how to leverage existing CouchDB functionality and add some additional fields on top of it.
CouchDB already has a mechanism for storing user documents, which we've already seen and used. We are going to use this same structure for the users of our application:
{ "_id": "org.couchdb.user:your_username", "_rev": "1-b9af54a7cdc392c2c298591f0dcd81f3", "name": "your_username", "password_sha": "3bc7d6d86da6lfed6d4d82e1e4d1c3ca587aecc8", "roles": [], "salt": "9812acc4866acdec35c903f0cc072c1d", "type": "user" }
These seven fields are required by CouchDB for users to operate correctly in CouchDB:
_id
is the unique identifier of the user. It needs to start withorg.couchdb.user:
and end with the same value of thename
attribute. These roles are enforced by the_auth
design document. We haven...