janmonschke / backbone-couchdb

A couchdb connector for backbone with support for real time changes.

Home Page:http://janmonschke.com/projects/backbone-couchdb.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possibility to pass include_docs when reading from views

cmadsen opened this issue · comments

Most of my views emits null to save space so I would like to pass include_docs:true to the jquery.couch view function

+1

For performance reasons many people use the include_docs directive instead of emit'ing the doc in the view logic. It would be great if we could add this functionality.

On line 87 of backbone-couchdb.js, it looks like this is already possible, assuming you send in {include_docs:true} in your options.

I haven't tested it yet, so I can't guarantee that it works. If it doesn't, I agree that this is an important request. Most of the CouchDB documentation I've read recommends specifically that views be written to emit (key, null) and use the the include_docs directive to pull in the docs, where necessary.

Even if this is possible to set this in opts, I think it might make sense to add a global config option for this - I imagine there will be many users who'd need {include_docs:true} more often than {include_docs:false}.

I have since tested this, and it does work as I suspected. Just fetch your collections like this:
collection.fetch({include_docs:true})
and you can use emit(key, null) in your views, already.

Fixed here #34