janmonschke/backbone-couchdb — pull request #33 by nickkitto (2012-01-23 04:28:43+00:00)
Title: Added support for startkey and endkey

Hey Jan,
I am using your backbone-couchdb library for an application and notice it was missing support for using the startkey and endkey as allowed in the couchdb code.
It works the same as how keys work (inside the db object inside a collection)

Here is an explanation of the logic to determine what can and can't exist in a request.

if ((coll.db != null) && (coll.db.view != null) && !(coll.db.startkey != null)) {
delete _opts.startkey;
delete _opts.endkey;
}

If there is no startkey, make sure startkey and endkey are null

if ((coll.db != null) && (coll.db.view != null) && !(coll.db.endkey != null)) {
delete _opts.endkey;
}

If there is no endkey, delete it

if ((coll.db != null) && (coll.db.view != null) && (coll.db.startkey != null)) {
delete _opts.keys;
}

If there is a startkey, delete key.

This may or may not be your intented functionality (startkey overrides key) but this could easily be changed.

Apologies if this is in the wrong format in anyway, as this is my first submission to github.

Regards,
Nick