mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 10:46:00 +00:00
export/import column map support
This commit is contained in:
21
packages/api/src/utility/ColumnMapTransformStream.js
Normal file
21
packages/api/src/utility/ColumnMapTransformStream.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const stream = require('stream');
|
||||
const { transformRowUsingColumnMap } = require('dbgate-tools');
|
||||
|
||||
class ColumnMapTransformStream extends stream.Transform {
|
||||
constructor(columns) {
|
||||
super({ objectMode: true });
|
||||
this.columns = columns;
|
||||
}
|
||||
_transform(chunk, encoding, done) {
|
||||
if (chunk.__isStreamHeader) {
|
||||
// skip stream header
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
this.push(transformRowUsingColumnMap(chunk, this.columns));
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ColumnMapTransformStream;
|
||||
Reference in New Issue
Block a user