node-entity
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -63,9 +63,15 @@ /** | ||
MongooseAdapter.prototype._create = function(itemData) { | ||
var self = this; | ||
return new Promise(function(resolve, reject) { | ||
var item = new this.Model(itemData); | ||
var item = new self.Model(itemData); | ||
item.save(function(err, document) { | ||
if (err) { return reject(err); } | ||
resolve(document); | ||
if (self._hasEagerLoad) { | ||
self._readOne(document._id).then(resolve, reject); | ||
} else { | ||
resolve(document); | ||
} | ||
}); | ||
}.bind(this)); | ||
}); | ||
}; | ||
@@ -191,4 +197,5 @@ | ||
if (!this.Model) { throw new Error('No Mongoose.Model defined, use setModel()'); } | ||
var self = this; | ||
return new Promise(function(resolve, reject) { | ||
this.readOne(id).then(function(doc) { | ||
self.readOne(id).then(function(doc) { | ||
if (!__.isObject(doc)) { | ||
@@ -199,11 +206,11 @@ return reject(new Error('record not found')); | ||
doc[key] = value; | ||
}, this); | ||
}); | ||
doc.save(function(err, document) { | ||
doc.save(function(err) { | ||
if (err) { return reject(err); } | ||
resolve(document); | ||
resolve(doc); | ||
}); | ||
}.bind(this), reject); | ||
}.bind(this)); | ||
}, reject); | ||
}); | ||
}; | ||
@@ -210,0 +217,0 @@ |
{ | ||
"name": "node-entity", | ||
"description": "The MVCe implementation for Node.js", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"homepage": "https://github.com/thanpolas/entity", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -475,2 +475,4 @@ # Entity | ||
- **v0.2.9**, *03 Jul 2014* | ||
- optimizations and fixes on eager loading for mongoose. | ||
- **v0.2.8**, *03 Jul 2014* | ||
@@ -477,0 +479,0 @@ - Introduce eager loading mechanisms. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81500
1921
518