Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up Sequelize.js to stream data instead of a promise / callback?

I am using MySQL and have a very large response (15,000+ rows). This takes.. well.. time. But I can start to process the first result right away. Can I set up a stream somehow with sequelize? If so, how?

like image 942
Shamoon Avatar asked Feb 28 '15 22:02

Shamoon


2 Answers

There is a related GitHub for this. It doesn't look like it will happen in the near future.

For now I am monitoring my console, saving the query that Sequelize generates, and then refactoring my code to run the query with node-mysql.

connection.query(mySavedQuery).stream().pipe(...)
like image 195
Aaron Shafovaloff Avatar answered Nov 13 '22 20:11

Aaron Shafovaloff


Also you can use node-sequelize-stream library.

like image 24
Nikolai Kovalenko Avatar answered Nov 13 '22 18:11

Nikolai Kovalenko