couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AL <>
Subject Using underscorejs in a couchapp list
Date Mon, 06 Aug 2012 17:17:03 GMT
Hi all,

I'm running archlinux and couchdb 1.2. I'm trying to develop a couchapp: 
although I could use couchdb only as a database, I like the idea of 
"self-containess" in couchapps. The application I want to build is 
fairly simple, consisting of list and detail views. I have a set of 
books described in a bibtex-like fashion, and I'm trying to serve a 
webpage that lists the whole collection, organized by year. Here is my 
view map:

     function(doc) {
       if (doc.application === "publication") {
         emit([doc.year, doc.title], doc);

I'd like to get a webpage consisting of several ul tags; one for every 
year. The getrow() function makes it easy to make one big list (1. 
opening the list, 2. creating a list element for every row, 3. closing 
the list) but for what I want to achieve it seems a little bit trickier.

My idea was to use underscorejs `_.sortBy` method to reorganize the data 
by year into a dictionary, to end up with something like this:

       '2009': [
         {'title': ' The Transformer -- Principles of Making Isotype 
Charts', ...},
         {'title': ' Verbindingen/Jonctions 10, Tracks in Electr(on)ic 
Fields', ...},
       '2012': [
         {'title': 'Tying the Story to Data: The graffiti Markup Field 
Recorder Challenged, GML', ...},
         {'title': 'Inside Photoshop', ...},

 From there, I'd be able to loop through each key and append to my html 
output an HTML list. Unfortunately, I'm unable to import underscorejs, 
as it seems like they have dropped support for commonjs. There are forks 
and similar libraries that are supposed to work, but whatever I try, it 
fails (see my question here:

So I'd like to know whether it is achievable in this way or another, and 
if my direction is correct, how I can use underscorejs (or similar) in a 

Thanks a lot,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message