Skip to content

Commit

Permalink
Missing part of 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
neumino committed Aug 14, 2015
1 parent d285e51 commit fb652e8
Showing 1 changed file with 59 additions and 50 deletions.
109 changes: 59 additions & 50 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,11 +898,11 @@ Model.prototype._parse = function(data, ungroup) {
var promise = data[i].validate();
if (promise instanceof Promise) {
promise.then(function() {
resolve(data[i])
resolve(data)
}).error(reject);
}
else {
resolve(data[i]);
resolve(data);
}
}).error(reject);
promises.push(promise);
Expand Down Expand Up @@ -935,10 +935,51 @@ Model.prototype._parse = function(data, ungroup) {
util.tryCatch(function() {
var reduction, newDoc;
for(var i=0; i<data.data.length; i++) {
reduction = [];
if (Array.isArray(data.data[i][1])) {
for(var j=0; j<data.data[i][1].length; j++) {
newDoc = new self(data.data[i][1][j]);
(function(i) {
reduction = [];
if (Array.isArray(data.data[i][1])) {
for(var j=0; j<data.data[i][1].length; j++) {
(function(j) {
newDoc = new self(data.data[i][1][j]);
newDoc.setSaved(true);

newDoc._emitRetrieve();

promise = util.hook({
postHooks: newDoc._getModel()._post.retrieve,
doc: newDoc,
async: newDoc._getModel()._async.retrieve,
fn: function() {}
})
if (promise instanceof Promise) {
promise.then(function() {
var promise = newDoc.validate();
if (promise instanceof Promise) {
promise.then(function() {
resolve(data)
}).error(reject);
}
else {
resolve(data);
}
}).error(reject);
promises.push(promise);
}
else {
promise = newDoc.validate();
if (promise instanceof Promise) promises.push(promise);
}

reduction.push(newDoc)
})(j);
}
result.push({
group: data.data[i][0],
reduction: reduction
})
}
else {
newDoc = new self(data.data[i][1]);
newDoc.setSaved(true);

newDoc._emitRetrieve();
Expand All @@ -953,10 +994,12 @@ Model.prototype._parse = function(data, ungroup) {
promise.then(function() {
var promise = newDoc.validate();
if (promise instanceof Promise) {
promise.then(resolve).error(reject);
promise.then(function() {
resolve(result)
}).error(reject);
}
else {
resolve();
resolve(result);
}
}).error(reject);
promises.push(promise);
Expand All @@ -966,48 +1009,12 @@ Model.prototype._parse = function(data, ungroup) {
if (promise instanceof Promise) promises.push(promise);
}

reduction.push(newDoc)

}
result.push({
group: data.data[i][0],
reduction: reduction
})
}
else {
newDoc = new self(data.data[i][1]);
newDoc.setSaved(true);

newDoc._emitRetrieve();

promise = util.hook({
postHooks: newDoc._getModel()._post.retrieve,
doc: newDoc,
async: newDoc._getModel()._async.retrieve,
fn: function() {}
})
if (promise instanceof Promise) {
promise.then(function() {
var promise = newDoc.validate();
if (promise instanceof Promise) {
promise.then(resolve).error(reject);
}
else {
resolve();
}
}).error(reject);
promises.push(promise);
}
else {
promise = newDoc.validate();
if (promise instanceof Promise) promises.push(promise);
result.push({
group: data.data[i][0],
reduction: newDoc
})
}

result.push({
group: data.data[i][0],
reduction: newDoc
})
}
})(i);
}
}, reject);
if (promises.length > 0) {
Expand Down Expand Up @@ -1040,7 +1047,9 @@ Model.prototype._parse = function(data, ungroup) {
promise.then(function() {
var promise = newDoc.validate();
if (promise instanceof Promise) {
promise.then(resolve).error(reject);
promise.then(function() {
resolve(newDoc);
}).error(reject);
}
else {
resolve(newDoc);
Expand Down

0 comments on commit fb652e8

Please sign in to comment.