This commit is contained in:
SPRINX0\prochazka 2024-09-10 15:42:22 +02:00
parent 8d865ab3b3
commit 18e6200c3b

View File

@ -21,7 +21,16 @@ const driver = {
return client;
},
// called for retrieve data (eg. browse in data grid) and for update database
async query(client, query) {
async query(client, query, options) {
if (options?.discardResult) {
await client.command({
query,
});
return {
rows: [],
columns: [],
};
} else {
const resultSet = await client.query({
query,
format: 'JSONCompactEachRowWithNamesAndTypes',
@ -38,10 +47,28 @@ const driver = {
rows: dataSet.slice(2).map((row) => _.zipObject(dataSet[0], row)),
columns,
};
}
},
// called in query console
async stream(client, query, options) {
try {
if (!query.match(/^\s*SELECT/i)) {
const resp = await client.command({
query,
});
// console.log('RESP', resp);
// const { rowsAffected } = resp || {};
// if (rowsAffected) {
// options.info({
// message: `${rowsAffected} rows affected`,
// time: new Date(),
// severity: 'info',
// });
// }
options.done();
return;
}
const resultSet = await client.query({
query,
format: 'JSONCompactEachRowWithNamesAndTypes',