Skip to content

Commit

Permalink
Added .list method
Browse files Browse the repository at this point in the history
  • Loading branch information
tanepiper committed Dec 27, 2010
1 parent fcb7ae7 commit c4b7deb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/cradle.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,20 @@ cradle.Connection.prototype.database = function (name) {
}
this.query('GET', ['_design', path[0], '_view', path[1]].join('/'), options, args.callback);
},

// Query a list, passing any options to the query string.
// Some query string parameters' values have to be JSON-encoded.
list: function (path, options) {
var args = new(Args)(arguments);
path = path.split('/');

if (typeof(options) === 'object') {
['key', 'startkey', 'endkey'].forEach(function (k) {
if (k in options) { options[k] = JSON.stringify(options[k]) }
});
}
this.query('GET', ['_design', path[0], '_list', path[1], path[2]].join('/'), options, args.callback);
},

push: function (doc) {},

Expand Down

0 comments on commit c4b7deb

Please sign in to comment.