east-rethink
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -14,4 +14,6 @@ 'use strict'; | ||
if (typeof this.params.database.migrationTable !== 'string') { | ||
this.params.database.migrationTable = 'migration'; | ||
if (typeof this.params.database !== 'function') { | ||
this.params.configure = (cb) => cb(null, params.database); | ||
} else { | ||
this.params.configure = this.params.database; | ||
} | ||
@@ -25,11 +27,24 @@ }; | ||
Adapter.prototype.configure = function (callback) { | ||
const self = this; | ||
self.params.configure((err, database) => { | ||
if (err) { | ||
return callback(err); | ||
} | ||
self.params.database = database; | ||
self.params.database.migrationTable = self.params.database.migrationTable || 'migration'; | ||
callback(); | ||
}); | ||
} | ||
Adapter.prototype.connect = function (callback) { | ||
const self = this; | ||
const settings = Hoek.clone(self.params.database.connection); | ||
const tableName = self.params.database.migrationTable; | ||
this.db = new Pensuer.Db(self.params.database.name, settings); | ||
this.db.table(self.params.tables); | ||
this.db.connect( (err) => { | ||
self.configure((err) => { | ||
if (err) { | ||
@@ -39,3 +54,7 @@ return callback(err); | ||
this.db.establish({ [tableName]: { purge: false } }, (err) => { | ||
const settings = Hoek.clone(self.params.database.connection); | ||
const tableName = self.params.database.migrationTable; | ||
this.db = new Pensuer.Db(self.params.database.name, settings); | ||
this.db.table(self.params.tables); | ||
this.db.connect( (err) => { | ||
@@ -46,3 +65,10 @@ if (err) { | ||
return callback(null, { db: self.db }); | ||
this.db.establish({ [tableName]: { purge: false } }, (err) => { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, { db: self.db }); | ||
}); | ||
}); | ||
@@ -49,0 +75,0 @@ }); |
{ | ||
"name": "east-rethink", | ||
"description": "rethinkdb adapter for \"east\" (node.js database migration tool)", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
6971
102