Permalink
Browse files

feat(project): Setup configurable debugging

  • Loading branch information...
RWOverdijk committed Oct 3, 2016
1 parent facf63c commit e46ae6319d9386294dac8edea7ec2ec27d886e80
Showing with 4 additions and 33 deletions.
  1. +0 −22 src/Query.ts
  2. +0 −11 src/QueryBuilder.ts
  3. +4 −0 src/Wetland.ts
@@ -2,12 +2,6 @@ import * as knex from 'knex';
import {Hydrator} from './Hydrator';
export class Query {
/**
* Log all queries when true.
*
* @type {boolean}
*/
private debug: Boolean = false;
/**
* @type {Hydrator}
@@ -30,28 +24,12 @@ export class Query {
this.hydrator = hydrator;
}
/**
* Enable debugging for this query.
*
* @returns {Query}
*/
public enableDebugging(): Query {
this.debug = true;
return this;
}
/**
* Execute the query.
*
* @returns {Promise<[]>}
*/
public execute(): Promise<Array<Object>> {
// @todo Change this to a module-wide debug mode that sets up listeners. https://github.com/SpoonX/wetland/issues/35
if (this.debug) {
console.log(this.getSQL());
}
return this.statement.then();
}
@@ -569,17 +569,6 @@ export class QueryBuilder<T> {
return this;
}
/**
* Enable debugging for the query.
*
* @returns {QueryBuilder}
*/
debug(): this {
this.query.enableDebugging();
return this;
}
/**
* Map provided values to columns.
*
@@ -112,6 +112,10 @@ export class Wetland {
* @returns {Wetland}
*/
public registerStore(store: string, config: PoolConfig | ReplicationConfig | SingleConfig): Wetland {
if (this.config.fetch('debug')) {
config.debug = true;
}
this.stores[store] = new Store(store, config);
// The first registered store is the default store.

0 comments on commit e46ae63

Please sign in to comment.