Comparing version 1.16.2 to 1.16.4
@@ -950,17 +950,19 @@ var schemaUtil = require(__dirname+'/schema.js'); | ||
for(var i=0; i<self[key].length; i++) { | ||
(function(key, i) { | ||
promisesMany.push(new Promise(function(resolve, reject) { | ||
self[key][i]._save(docToSave[key], saveAll, savedModel).then(function() { | ||
// self.__proto__._links will be saved in saveLinks | ||
if (self[key][i].__proto__._parents._belongsLinks[self._getModel()._name] == null) { | ||
self[key][i].__proto__._parents._belongsLinks[self._getModel()._name] = []; | ||
} | ||
self[key][i].__proto__._parents._belongsLinks[self._getModel()._name].push({ | ||
doc: self, | ||
key: key | ||
}); | ||
resolve(); | ||
}).error(reject); | ||
})) | ||
})(key, i) | ||
if (util.isPlainObject(self[key][i])) { // Save only if we have a full object, and not just a key | ||
(function(key, i) { | ||
promisesMany.push(new Promise(function(resolve, reject) { | ||
self[key][i]._save(docToSave[key], saveAll, savedModel).then(function() { | ||
// self.__proto__._links will be saved in saveLinks | ||
if (self[key][i].__proto__._parents._belongsLinks[self._getModel()._name] == null) { | ||
self[key][i].__proto__._parents._belongsLinks[self._getModel()._name] = []; | ||
} | ||
self[key][i].__proto__._parents._belongsLinks[self._getModel()._name].push({ | ||
doc: self, | ||
key: key | ||
}); | ||
resolve(); | ||
}).error(reject); | ||
})) | ||
})(key, i) | ||
} | ||
} | ||
@@ -1006,5 +1008,10 @@ } | ||
for(var i=0; i<self[key].length; i++) { | ||
if (self[key][i].isSaved() === true) { | ||
newKeys[self[key][i][joins[key].rightKey]] = true; | ||
if (util.isPlainObject(self[key][i])) { | ||
if (self[key][i].isSaved() === true) { | ||
newKeys[self[key][i][joins[key].rightKey]] = true; | ||
} | ||
} | ||
else { // self[key][i] is just the key | ||
newKeys[self[key][i]] = true; | ||
} | ||
} | ||
@@ -1011,0 +1018,0 @@ |
@@ -954,3 +954,3 @@ var util = require(__dirname+'/util.js'); | ||
} | ||
Model.prototype.save = function(docs) { | ||
Model.prototype.save = function(docs, options) { | ||
var self = this; | ||
@@ -978,4 +978,12 @@ var r = self._getModel()._thinky.r; | ||
} | ||
r.table(self.getTableName()).insert(copies, {returnChanges: true}).run().then(function(results) { | ||
if ((results.errors === 0) && (results.inserted === docs.length)) { | ||
var _options; | ||
if (util.isPlainObject(options)) { | ||
_options = util.deepCopy(options); | ||
} | ||
else { | ||
_options = {}; | ||
} | ||
_options.returnChanges = true; | ||
r.table(self.getTableName()).insert(copies, _options).run().then(function(results) { | ||
if (results.errors === 0) { | ||
for(var i=0; i<results.changes.length; i++) { | ||
@@ -982,0 +990,0 @@ docs[i]._merge(results.changes[i].new_val); |
@@ -213,7 +213,7 @@ var Promise = require('bluebird'); | ||
} | ||
else if ((typeof result.getType === 'function') && (result.getType() === 'feed')) { | ||
else if ((result != null) && (typeof result.getType === 'function') && (result.getType() === 'feed')) { | ||
var feed = new Feed(result, self._model); | ||
resolve(feed); | ||
} | ||
else if ((typeof result.getType === 'function') && (result.getType() === 'atomFeed')) { | ||
else if ((result != null) && (typeof result.getType === 'function') && (result.getType() === 'atomFeed')) { | ||
result.next().then(function(initial) { | ||
@@ -220,0 +220,0 @@ var value = initial.new_val || {}; |
{ | ||
"name": "thinky", | ||
"version": "1.16.2", | ||
"version": "1.16.4", | ||
"description": "RethinkDB ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/thinky.js", |
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
195963
5279