Update lib/adapters/cradle.js

fixed an issue where if no filters were passed in, the .all query would throw an exception
This commit is contained in:
Muneeb Samuels 2012-10-19 23:49:01 +03:00
parent 03f9c24642
commit 0203d52728
1 changed files with 8 additions and 2 deletions

View File

@ -260,9 +260,15 @@ CradleAdapter.prototype.count = function(model, callback, where) {
};
CradleAdapter.prototype.models = function(model, filter, callback, func) {
var limit = 99999999; // maybe there is a better way to do this?
var skip = 0;
if (filter != null) {
limit = filter.limit || limit;
skip = filter.skip ||skip;
}
this.client.all(
// maybe there is a better way to do this?
{include_docs:true, limit: filter.limit == null ? 9999999999 : filter.limit, skip: filter.skip == null ? 0 : filter.skip},
{include_docs:true, limit: limit, skip: skip},
errorHandler(callback, function(res, cb) {
var docs = res.map(function(doc) {
return idealize(doc);