Allows connector property to be a string
This commit is contained in:
parent
3051f0457f
commit
7ce6cfc9ab
|
@ -152,11 +152,9 @@ DataSource.prototype.setup = function(name, settings) {
|
||||||
var connector;
|
var connector;
|
||||||
|
|
||||||
// support single settings object
|
// support single settings object
|
||||||
if(name && typeof name === 'object') {
|
if(name && typeof name === 'object' && !settings) {
|
||||||
if(!name.initialize) {
|
|
||||||
settings = name;
|
settings = name;
|
||||||
name = undefined;
|
name = undefined;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof settings === 'object') {
|
if(typeof settings === 'object') {
|
||||||
|
@ -164,8 +162,8 @@ DataSource.prototype.setup = function(name, settings) {
|
||||||
connector = settings;
|
connector = settings;
|
||||||
} else if(settings.connector) {
|
} else if(settings.connector) {
|
||||||
connector = settings.connector;
|
connector = settings.connector;
|
||||||
} else if(settings.connector) {
|
} else if(settings.adapter) {
|
||||||
connector = settings.connector;
|
connector = settings.adapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,13 +191,20 @@ DataSource.prototype.setup = function(name, settings) {
|
||||||
} else {
|
} else {
|
||||||
// try foreign connector
|
// try foreign connector
|
||||||
try {
|
try {
|
||||||
connector = require('loopback-connector-' + name);
|
if(name.indexOf('loopback-connector-') === -1) {
|
||||||
|
name = 'loopback-connector-' + name;
|
||||||
|
}
|
||||||
|
connector = require(name);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return console.log('\nWARNING: LoopbackData connector "' + name + '" is not installed,\nso your models would not work, to fix run:\n\n npm install loopback-connector-' + name, '\n');
|
return console.log('\nWARNING: LoopbackData connector "' + name + '" is not installed,\nso your models would not work, to fix run:\n\n npm install loopback-connector-' + name, '\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if('string' === typeof connector) {
|
||||||
|
connector = require(connector);
|
||||||
|
}
|
||||||
|
|
||||||
if (connector) {
|
if (connector) {
|
||||||
var postInit = function postInit() {
|
var postInit = function postInit() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue