couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Pieper <j-pie...@gmx.net>
Subject is this the "best" way to display a list of documents?
Date Sat, 27 Nov 2010 23:49:48 GMT
I am new to CouchDB so please be gentle with me :-) I think you guys can help me 
without checking any manuals/guides etc. because it's not very difficult what i 
am searching for.

After importing all my contacts into my own local CouchDB instance I want to set 
up a small HTML interface to show them. So i want to have a list of all contacts 
shown by their names.

- Jessica Alba
- George Clooney
- Charlie Sheen
- ...

## File: <app>/_attachments/index.html ############################

<div id="contacts"></div>
<script type="text/javascript" charset="utf-8">
   $.couch.app(function(app) {
     $("#contacts").evently("contacts", app);
   });
</script>

## File <app>/evently/contacts/_init/data.js ######################

function(data) {
   return {contacts: data.rows.map(row) {
     return {"name": row.value.name};
   })};
}

## File: <app>/evently/contacts/_init/mustache.html ###############

<ul>
   {{#contacts}}
     <li>{{name}}</li>
   {{/contacts}}
</ul>

## File <app>/evently/contacts/_init/query.json ###################

{"view": "contacts", "ascending": true}

## File: <app>/views/contacts/map.js ##############################

function(doc) {
   if (doc.type == "contact") {
     emit(doc.name, doc);
   }
}

## Example document ###############################################

{
   "_id": "...",
   "_rev": "...",
   "type": "contact",
   "name": "Jessica Alba"
}

###################################################################

It's working fine for me but can you please tell me whether this is a good way 
to display a list of documents? Is there another/better way?

with regards,
Jan Pieper

Mime
View raw message