Skip to content

Commit 9791dc6

Browse files
committed
refactor(prefix): update prefix handling and table initialization logic
1 parent 4183ff2 commit 9791dc6

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,19 @@ class ErrsolePostgres extends EventEmitter {
5656
constructor (options = {}) {
5757
super();
5858

59-
const { tablePrefix = '', ...pgOptions } = options;
59+
let { tablePrefix, ...pgOptions } = options;
60+
tablePrefix = tablePrefix ? `errsole_${tablePrefix.toLowerCase().replace(/[^a-z0-9]/g, '')}` : 'errsole';
6061

61-
this.tablePrefix = tablePrefix
62-
? `errsole_${tablePrefix.toLowerCase().replace(/[^a-z0-9]/g, '')}`
63-
: 'errsole';
64-
65-
this.logsTable = `${this.tablePrefix}_logs_v2`;
66-
this.usersTable = `${this.tablePrefix}_users`;
67-
this.configTable = `${this.tablePrefix}_config`;
68-
this.notificationsTable = `${this.tablePrefix}_notifications`;
62+
this.isConnectionInProgress = true;
63+
this.pool = new Pool(pgOptions);
64+
this.logsTable = `${tablePrefix}_logs_v2`;
65+
this.usersTable = `${tablePrefix}_users`;
66+
this.configTable = `${tablePrefix}_config`;
67+
this.notificationsTable = `${tablePrefix}_notifications`;
6968

7069
this.name = require('../package.json').name;
7170
this.version = require('../package.json').version || '0.0.0';
7271

73-
this.isConnectionInProgress = true;
74-
this.pool = new Pool(pgOptions);
75-
7672
this.pendingLogs = [];
7773
this.batchSize = 100;
7874
this.flushInterval = 1000;

0 commit comments

Comments
 (0)