Skip to content

Commit

Permalink
Merge pull request #51 from mikeymckay/master
Browse files Browse the repository at this point in the history
Support for the key (singular) option on views
  • Loading branch information
janmonschke committed Jul 28, 2012
2 parents 81bcc19 + f61ebda commit 88aa803
Show file tree
Hide file tree
Showing 2 changed files with 308 additions and 277 deletions.
41 changes: 22 additions & 19 deletions backbone-couchdb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,29 @@ Backbone.couch_connector = con =
opts.complete res

# support view querying opts http://wiki.apache.org/couchdb/HTTP_view_API
if opts.limit?
_opts.limit = opts.limit;

if opts.skip?
_opts.skip = opts.skip;

if opts.include_docs?
_opts.include_docs = opts.include_docs;

if opts.startkey?
_opts.startkey = opts.startkey;

if opts.endkey?
_opts.endkey = opts.endkey;

if opts.startkey_docid?
_opts.startkey_docid = opts.startkey_docid;

if opts.endkey_docid?
_opts.endkey_docid = opts.endkey_docid;
view_options = [
"key"
"keys"
"startkey"
"startkey_docid"
"endkey"
"endkey_docid"
"limit"
"stale"
"descending"
"skip"
"group"
"group_level"
"reduce"
"include_docs"
"inclusive_end"
"update_seq"
]

for option in view_options
if opts[option]?
_opts[option] = opts[option]

# delete keys if a custom view is requested but no custom keys
if coll.db? and coll.db.view? and not coll.db.keys?
Expand Down
Loading

0 comments on commit 88aa803

Please sign in to comment.