Simplify the id lookup

This commit is contained in:
Raymond Feng 2014-09-04 09:32:38 -07:00
parent 5c7a9aee3a
commit 057d39d5bb
1 changed files with 3 additions and 6 deletions

View File

@ -39,15 +39,12 @@ function DataAccessObject() {
}
}
function idName(m) {
return m.getDataSource().idName
? m.getDataSource().idName(m.modelName) : 'id';
return m.definition.idName() || 'id';
}
function getIdValue(m, data) {
return data && data[m.getDataSource().idName(m.modelName)];
return data && data[idName(m)];
}
function setIdValue(m, data, value) {
@ -330,7 +327,7 @@ DataAccessObject.findByIds = function(ids, cond, cb) {
cond = {};
}
var pk = this.dataSource.idName(this.modelName) || 'id';
var pk = idName(this);
if (ids.length === 0) {
process.nextTick(function() { cb(null, []); });
return;