I'm building with node.js and CouchDB, and I think the pair are a perfect
marriage. I wanted to share something that I discovered the other day.

I'm building a simplified data layer in my node.js+CouchDB application
framework WIN ( github.com/mathgladiator/win ) and I was thinking that
making applications portable with design documents was kind of a pain to
install without some kind of framework support. I'm assuming the application
is going to operate in a single database, and I'm going to a have a bunch of
indices/views-maps work within a single design document. Since node.js is
JavaScript and functions in v8 have a toString method, I can merge code from
application logic to the design document. Here is the WIN code to build an
index of users.

$.indexer("users_by_user_id",function(doc) {
        if(doc.ns=="user")
                emit(doc.id,doc);
});

I can work in the same document and deploy without worrying about what
design documents already exist.

Reply via email to