Last active
December 13, 2018 14:28
-
-
Save manelet/93c8cbb8a5dc760801fd7d8f7ccb833c to your computer and use it in GitHub Desktop.
Streams MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { stream } = require('@apartum/mysql-wrapper')(require('./config')) | |
const writeStream = require('fs').createWriteStream('./src/hola.txt') | |
const Transform = require('stream').Transform | |
const transformStream = new Transform({ | |
objectMode: true, | |
highWatermark: 1, | |
transform (chunk, encoding, done) { | |
chunk.es = 'ASDASDASD' | |
// this.push(JSON.stringify(chunk)) | |
done(null, JSON.stringify(chunk)) | |
} | |
}) | |
async function start () { | |
stream('SELECT * FROM countries') | |
.pipe(transformStream) | |
.pipe(writeStream) | |
} | |
start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment