Prevent autoAttach from overriding existing data source

This commit is contained in:
Raymond Feng 2014-01-20 14:32:47 -08:00
parent 73390a6be8
commit 8a114c635f
1 changed files with 2 additions and 1 deletions

View File

@ -243,7 +243,8 @@ loopback.autoAttach = function() {
Object.keys(models).forEach(function(modelName) { Object.keys(models).forEach(function(modelName) {
var ModelCtor = models[modelName]; var ModelCtor = models[modelName];
if(ModelCtor) { // Only auto attach if the model doesn't have an explicit data source
if(ModelCtor && (!(ModelCtor.dataSource instanceof DataSource))) {
loopback.autoAttachModel(ModelCtor); loopback.autoAttachModel(ModelCtor);
} }
}); });