Strict adapter checking
This commit is contained in:
parent
3dc24b8f51
commit
05a6d686aa
|
@ -27,28 +27,13 @@ module.exports = function init(root) {
|
|||
var confFile = (root || app.root) + '/config/database';
|
||||
var config = {};
|
||||
|
||||
if (existsSync(confFile + '.js')) {
|
||||
try {
|
||||
config = require(confFile + '.js');
|
||||
} catch (e) {
|
||||
console.log('Could not load config/database.js');
|
||||
throw e;
|
||||
}
|
||||
} else if (existsSync(confFile + '.json')) {
|
||||
try {
|
||||
config = JSON.parse(fs.readFileSync(confFile + '.json', 'utf-8'))[app.set('env')];
|
||||
} catch (e) {
|
||||
console.log('Could not parse config/database.json');
|
||||
throw e;
|
||||
}
|
||||
} else if (existsSync(confFile + '.yml')) {
|
||||
try {
|
||||
config = railway.utils.readYaml(confFile + '.yml')[app.set('env')];
|
||||
} catch (e) {
|
||||
console.log('Could not parse config/database.yml');
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
config = require(confFile)[app.set('env')];
|
||||
} catch (e) {
|
||||
console.log('Could not load config/database.{js|json|yml}');
|
||||
throw e;
|
||||
}
|
||||
|
||||
// when driver name started with point - look for driver in app root (relative path)
|
||||
if (config.driver && config.driver.match(/^\./)) {
|
||||
config.driver = path.join(app.root, config.driver);
|
||||
|
@ -57,6 +42,8 @@ module.exports = function init(root) {
|
|||
var schema = new Schema(config && config.driver || 'memory', config);
|
||||
schema.log = log;
|
||||
|
||||
if (!schema.adapter) throw new Error('Adapter is not defined');
|
||||
|
||||
if (schema.waitForConnect) {
|
||||
schema.on('connected', function() {
|
||||
loadSchema(schema, railway, app, models);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "jugglingdb",
|
||||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, couchdb, postgres, sqlite",
|
||||
"version": "0.2.0-4",
|
||||
"version": "0.2.0-6",
|
||||
"author": "Anatoliy Chakkaev <rpm1602@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue