diff --git a/lib/datasource.js b/lib/datasource.js index cd391d84..fde1e7ce 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -152,11 +152,9 @@ DataSource.prototype.setup = function(name, settings) { var connector; // support single settings object - if(name && typeof name === 'object') { - if(!name.initialize) { + if(name && typeof name === 'object' && !settings) { settings = name; name = undefined; - } } if(typeof settings === 'object') { @@ -164,8 +162,8 @@ DataSource.prototype.setup = function(name, settings) { connector = settings; } else if(settings.connector) { connector = settings.connector; - } else if(settings.connector) { - connector = settings.connector; + } else if(settings.adapter) { + connector = settings.adapter; } } @@ -193,13 +191,20 @@ DataSource.prototype.setup = function(name, settings) { } else { // try foreign connector try { - connector = require('loopback-connector-' + name); + if(name.indexOf('loopback-connector-') === -1) { + name = 'loopback-connector-' + name; + } + connector = require(name); } 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'); } } } + if('string' === typeof connector) { + connector = require(connector); + } + if (connector) { var postInit = function postInit() {