Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
feat: add multi schema feature (#44)
Browse files Browse the repository at this point in the history
support schema other than "public"

Co-authored-by: David Sooter <david.sooter@ext.sys.aok.de>
  • Loading branch information
d-sooter and David Sooter authored Nov 17, 2020
1 parent 1bf1260 commit 2eb6835
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ For local development you can provide the credentials in the file `default-env.j
"port": "5432",
"database": "dbname",
"user": "postgres",
"password": "postgres"
"password": "postgres",
"schema":"public"
}
}
]
Expand Down
5 changes: 5 additions & 0 deletions lib/pg/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ module.exports = class PostgresDatabase extends cds.DatabaseService {
}
this._pool = new Pool(this.options.credentials)

// SET SCHEMA
if (this.options.credentials && this.options.credentials.schema) {
this._pool.query(`SET search_path TO '${this.options.credentials.schema}';`)
}

// Mapping of the pg specific executions. Inspired by the SQLite and HANA adapters.
// We call the default run handlers but pass in our custom execution functions.
this._execute = execute
Expand Down

0 comments on commit 2eb6835

Please sign in to comment.