stream header flag + export from mongo

This commit is contained in:
Jan Prochazka
2021-04-08 17:49:57 +02:00
parent a5d37eb528
commit 20fccf51d9
9 changed files with 83 additions and 12 deletions

View File

@@ -8,10 +8,16 @@ class StringifyStream extends stream.Transform {
this.wasHeader = false;
}
_transform(chunk, encoding, done) {
let skip = false;
if (!this.wasHeader) {
if (this.header) this.push(JSON.stringify(chunk) + '\n');
skip =
(chunk.__isStreamHeader ||
// TODO remove isArray test
Array.isArray(chunk.columns)) &&
!this.header;
this.wasHeader = true;
} else {
}
if (!skip) {
this.push(JSON.stringify(chunk) + '\n');
}
done();