Merge remote-tracking branch 'origin/master'
Conflicts: lib/adapters/cradle.js
This commit is contained in:
commit
53272e6fd6
|
@ -221,7 +221,7 @@ CradleAdapter.prototype.updateOrCreate = function(model, data, callback) {
|
|||
if(err) {
|
||||
this.create(model, data, callback);
|
||||
} else {
|
||||
this.updateAttributes(model, data.id, data, callback);
|
||||
this.updateAttributes(mode, data.id, data, callback);
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
|
@ -260,43 +260,24 @@ CradleAdapter.prototype.count = function(model, callback, where) {
|
|||
};
|
||||
|
||||
CradleAdapter.prototype.models = function(model, filter, callback, func) {
|
||||
var limit = 200;
|
||||
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;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
this.client.all(
|
||||
{include_docs:true, limit: limit, skip: skip},
|
||||
errorHandler(callback, function(res, cb) {
|
||||
var docs = res.map(function(doc) {
|
||||
return idealize(doc);
|
||||
});
|
||||
var filtered = filtering(docs, model, filter, this._models)
|
||||
|
||||
self.client.save('_design/'+model, {
|
||||
views : {
|
||||
all : {
|
||||
map : 'function(doc) { if (doc.nature == "'+model+'") { emit(doc._id, doc); } }'
|
||||
}
|
||||
}
|
||||
}, function() {
|
||||
self.client.view(model+'/all', {include_docs:true, limit:limit, skip:skip}, errorHandler(callback, function(res, cb) {
|
||||
var docs = res.map(function(doc) {
|
||||
return idealize(doc);
|
||||
});
|
||||
var filtered = filtering(docs, model, filter, this._models)
|
||||
|
||||
func ? func(filtered, cb) : cb(filtered);
|
||||
}.bind(self)));
|
||||
});
|
||||
|
||||
// this.client.all(
|
||||
// {include_docs:true, limit: limit, skip: skip},
|
||||
// errorHandler(callback, function(res, cb) {
|
||||
// var docs = res.map(function(doc) {
|
||||
// return idealize(doc);
|
||||
// });
|
||||
// var filtered = filtering(docs, model, filter, this._models)
|
||||
|
||||
// func ? func(filtered, cb) : cb(filtered);
|
||||
// }.bind(this))
|
||||
// );
|
||||
func ? func(filtered, cb) : cb(filtered);
|
||||
}.bind(this))
|
||||
);
|
||||
};
|
||||
|
||||
CradleAdapter.prototype.all = function(model, filter, callback) {
|
||||
|
|
Loading…
Reference in New Issue