Mysql bulk insert but from arrays of objects

I looked at this answer

I am looking to be able to insert rows from a previous select request into nodejs and use the same RowDataPacket and pass it to another insert request.

For example, the result of a previous call

 [ RowDataPacket { user_id: 1024, session_id: 3, notification_id: 1 }, RowDataPacket { user_id: 1028, session_id: 3, notification_id: 2 } ] ] 

after insertion

 var sql = 'INSERT INTO user_session_notification(user_id, session_id, notification_id) VALUES ?' var values = []; // ??? 
0
node-mysql
Sep 18 '16 at 21:52
source share
1 answer

Can you use ORM? if so, you can use Sequelize ORM for node js with mysql driver. This ORM has a function for volume insertion by clicking this link to see the volume insert of documentation. if not, you need to get the data from the selection, and then combine the data (object) into an array before inserting the insert. Hope you can help

0
Sep 19 '16 at 2:24
source share



All Articles