mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-08 07:48:40 +01:00
feat(PostgreSQL): read-only mode
This commit is contained in:
parent
4437d44486
commit
5d48fe08c7
@ -54,5 +54,6 @@ module.exports = {
|
||||
triggerTableInName: true,
|
||||
triggerOnlyRename: false,
|
||||
triggerEnableDisable: true,
|
||||
languages: ['sql', 'plpgsql', 'c', 'internal']
|
||||
languages: ['sql', 'plpgsql', 'c', 'internal'],
|
||||
readOnlyMode: true
|
||||
};
|
||||
|
@ -105,10 +105,19 @@ export class PostgreSQLClient extends AntaresCore {
|
||||
const client = new Client(dbConfig);
|
||||
await client.connect();
|
||||
this._connection = client;
|
||||
|
||||
if (this._params.readonly)
|
||||
await this.raw('SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY');
|
||||
}
|
||||
else {
|
||||
const pool = new Pool({ ...dbConfig, max: this._poolSize });
|
||||
this._connection = pool;
|
||||
|
||||
if (this._params.readonly) {
|
||||
this._connection.on('connect', connection => {
|
||||
connection.query('SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user