mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-08 15:58:45 +01:00
feat(PostgreSQL): read-only mode
This commit is contained in:
parent
4437d44486
commit
5d48fe08c7
@ -54,5 +54,6 @@ module.exports = {
|
|||||||
triggerTableInName: true,
|
triggerTableInName: true,
|
||||||
triggerOnlyRename: false,
|
triggerOnlyRename: false,
|
||||||
triggerEnableDisable: true,
|
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);
|
const client = new Client(dbConfig);
|
||||||
await client.connect();
|
await client.connect();
|
||||||
this._connection = client;
|
this._connection = client;
|
||||||
|
|
||||||
|
if (this._params.readonly)
|
||||||
|
await this.raw('SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const pool = new Pool({ ...dbConfig, max: this._poolSize });
|
const pool = new Pool({ ...dbConfig, max: this._poolSize });
|
||||||
this._connection = pool;
|
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