Use type converted data when writing back to database.
This allows foreignKey types and other custom types to be converted into natvie values before writing them to the database.
This commit is contained in:
parent
61a54da418
commit
abd46961da
|
@ -847,6 +847,7 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb
|
||||||
var inst = this;
|
var inst = this;
|
||||||
var Model = this.constructor
|
var Model = this.constructor
|
||||||
var model = Model.modelName;
|
var model = Model.modelName;
|
||||||
|
var typedData = {};
|
||||||
|
|
||||||
if (typeof data === 'function') {
|
if (typeof data === 'function') {
|
||||||
cb = data;
|
cb = data;
|
||||||
|
@ -873,9 +874,10 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb
|
||||||
|
|
||||||
for (var key in data) {
|
for (var key in data) {
|
||||||
inst[key] = data[key];
|
inst[key] = data[key];
|
||||||
|
typedData[key] = inst.__data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst), inst.constructor._forDB(data), function (err) {
|
inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst), inst.constructor._forDB(typedData), function (err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
// update $was attrs
|
// update $was attrs
|
||||||
for (var key in data) {
|
for (var key in data) {
|
||||||
|
|
Loading…
Reference in New Issue