ee-soa-service
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -667,18 +667,36 @@ | ||
if(Object.hasOwnProperty.call(this.specs.hasMany, withModel)) { | ||
this._getSingleModel(queryData, baseQuery, function(err, entity) { | ||
queryData.getContent(function(err, content) { | ||
if(err) return callback(err); | ||
if(entity) { | ||
var filterForWithModel = {}; | ||
filterForWithModel[this.specs.hasMany[withModel].primaryKey] = referenceId; | ||
if(content) { | ||
if(Object.hasOwnProperty.call(content, 'undefined')) | ||
return callback(new Error('[' + this.table + '] try to set variable "undefined"!')); | ||
entity[withModel].push(this.root[withModel](filterForWithModel)); | ||
entity.save(function(err, result) { | ||
if(err) return callback(err); | ||
content[this.specs.hasMany[withModel].table[this.table]] = id; | ||
content[this.specs.hasMany[withModel].table[withModel]] = referenceId; | ||
this.listOne(queryData, callback); | ||
var record = (baseQuery || new this.root[this.specs.hasMany[withModel].table.name]()).setValues(content); | ||
record.save(function(err, newRecord) { | ||
callback(err, newRecord); | ||
}.bind(this)); | ||
} | ||
else { | ||
this._getSingleModel(queryData, baseQuery, function(err, entity) { | ||
if(err) return callback(err); | ||
}.bind(this)); | ||
if(entity) { | ||
var filterForWithModel = {}; | ||
filterForWithModel[this.specs.hasMany[withModel].primaryKey] = referenceId; | ||
entity[withModel].push(this.root[withModel](filterForWithModel)); | ||
entity.save(function(err, result) { | ||
if(err) return callback(err); | ||
this.listOne(queryData, callback); | ||
}.bind(this)); | ||
} | ||
}.bind(this)); | ||
} | ||
}.bind(this)); | ||
} | ||
@@ -742,11 +760,10 @@ } | ||
if(err) return callback(err, data); | ||
if(!data) return callback(new Error('relation not found'), null); | ||
if(data) { | ||
data[withModel] = null; | ||
data.save(function(err, result) { | ||
if(err) return callback(err); | ||
data[withModel] = null; | ||
data.save(function(err, result) { | ||
if(err) return callback(err); | ||
this.listOne(queryData, callback); | ||
}.bind(this)); | ||
} | ||
this.listOne(queryData, callback); | ||
}.bind(this)); | ||
@@ -764,7 +781,6 @@ }.bind(this)); | ||
if(err) return callback(err); | ||
if(!data) return callback(new Error('relation not found'), null); | ||
if(data) { | ||
data[this.specs.belongsTo[withModel].targetColumn] = null; | ||
} | ||
data[this.specs.belongsTo[withModel].targetColumn] = null; | ||
data.save(function(err, result) { | ||
@@ -774,3 +790,3 @@ if(err) return callback(err); | ||
this.listOne(queryData, callback); | ||
}.bind(this)) | ||
}.bind(this)); | ||
@@ -788,2 +804,3 @@ }.bind(this)); | ||
if(err) return callback(err); | ||
if(!mapping) return callback(new Error('relation not found'), null); | ||
@@ -790,0 +807,0 @@ mapping.delete(function(err) { |
@@ -5,3 +5,3 @@ { | ||
, "keywords" : ["ee", "soa", "service"] | ||
, "version" : "0.2.2" | ||
, "version" : "0.2.3" | ||
, "author": { | ||
@@ -8,0 +8,0 @@ "name" : "Tobias Kneubuehler" |
66527
1145