clickhouse import

This commit is contained in:
Jan Prochazka
2024-09-12 15:39:48 +02:00
parent 086bc0d9f3
commit b232263708
5 changed files with 42 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
const { createBulkInsertStreamBase } = global.DBGATE_PACKAGES['dbgate-tools'];
const _ = require('lodash');
/**
*
* @param {import('dbgate-types').EngineDriver} driver
*/
function createOracleBulkInsertStream(driver, stream, pool, name, options) {
const writable = createBulkInsertStreamBase(driver, stream, pool, name, {
...options,
// this is really not used, send method below is used instead
commitAfterInsert: true,
});
writable.send = async () => {
await pool.insert({
table: name.pureName,
values: writable.buffer,
format: 'JSONEachRow',
});
writable.buffer = [];
};
return writable;
}
module.exports = createOracleBulkInsertStream;