Skip to content

Commit 827c2e6

Browse files
authored
✨: add schema support (#668)
1 parent a04ca96 commit 827c2e6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/postgres/src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ declare namespace KeyvPostgres {
2525
uri?: string | undefined;
2626
table?: string | undefined;
2727
keySize?: number | undefined;
28+
schema?: string | 'public';
2829
ssl?: any | undefined;
2930
}
3031
}

packages/postgres/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ class KeyvPostgres extends EventEmitter {
1717
.then(data => data.rows);
1818
});
1919
this.opts = {table: 'keyv',
20+
schema: 'public',
2021
keySize: 255, ...options};
2122

22-
const createTable = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
23+
const createTable = `CREATE TABLE IF NOT EXISTS ${this.opts.schema}.${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
2324

2425
const connected = this.opts.connect()
2526
.then(query => query(createTable).then(() => query))

0 commit comments

Comments
 (0)