Automatically convert strings to connectors if they are LoopBack connectors
This commit is contained in:
parent
6179476030
commit
1e3bfc6c18
|
@ -73,6 +73,8 @@ app.model = function (Model, config) {
|
|||
this.models[classify(modelName)] =
|
||||
this.models[camelize(modelName)] = modelFromConfig(modelName, config, this);
|
||||
|
||||
this.model(Model);
|
||||
|
||||
return Model;
|
||||
}
|
||||
|
||||
|
@ -235,6 +237,19 @@ function camelize(str) {
|
|||
}
|
||||
|
||||
function dataSourcesFromConfig(config) {
|
||||
var connectorPath;
|
||||
|
||||
assert(typeof config === 'object',
|
||||
'cannont create data source without config object');
|
||||
|
||||
if(typeof config.connector === 'string') {
|
||||
connectorPath = path.join(__dirname, 'connectors', config.connector+'.js');
|
||||
|
||||
if(fs.existsSync(connectorPath)) {
|
||||
config.connector = require(connectorPath);
|
||||
}
|
||||
}
|
||||
|
||||
return require('./loopback').createDataSource(config);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue