readonly sessions on mongo (+checks on BE)

This commit is contained in:
Jan Prochazka
2022-03-17 13:17:30 +01:00
parent 7d196c7c62
commit 8f1d76fd2a
8 changed files with 51 additions and 13 deletions

View File

@@ -135,10 +135,20 @@ function handleStream(driver, resultIndexHolder, sql) {
});
}
function ensureExecuteCustomScript(driver) {
if (driver.readOnlySessions) {
return;
}
if (storedConnection.isReadOnly) {
throw new Error('Connection is read only');
}
}
async function handleConnect(connection) {
storedConnection = connection;
const driver = requireEngineDriver(storedConnection);
ensureExecuteCustomScript(driver);
systemConnection = await connectUtility(driver, storedConnection);
for (const [resolve] of afterConnectCallbacks) {
resolve();