Reputation: 296
I'm currently using knex to query my database and stream the results into a CSV file uploaded on s3.
However, I'm struggling to find a way to pass the column names so they constitute the first row of my csv file.
Here is my code:
const stringifier = Stringify()
knex.raw('SELECT id, name FROM table LIMIT 20').stream().pipe(stringifier)
.pipe(gzip)
.pipe(s3WritableStream);
This only send each row.
What should I do to have the name of each column included as the first row in the CSV?
Thank you!
Upvotes: 0
Views: 604
Reputation: 296
Found the solution. Just add "header" to stringify:
const stringifier = Stringify({
header:true
})
Upvotes: 1