修复高级模型下的belongsTo的错误

This commit is contained in:
welefen 2014-06-15 15:27:19 +08:00
parent 121f8cfa38
commit e00a9d7416

View File

@ -156,7 +156,7 @@ module.exports = Model(function(){
return mapOptions.model.initPromise().then(function(){
mapKey = mapOptions.model.getModelName().toLowerCase() + "_id";
mapfKey = mapOptions.model.getPk();
var where = self.parseRelationWhere(data, mapOptions.mapKey, mapOptions.mapfKey);
var where = self.parseRelationWhere(data, mapKey, mapfKey);
mapOptions.model.where(where);
return mapOptions.model.select();
}).then(function(mapData){
@ -229,6 +229,9 @@ module.exports = Model(function(){
var value = data.map(function(item){
return item[mapKey];
});
if (value.length === 0) {
value = [0];
}
return getObject(mapfKey, ["IN", value]);
}
return getObject(mapfKey, data[mapKey]);