Vinicius Martin
Vinicius Martin

Reputation: 189

resultId in a multiple insert Mysql Node JS

I am using Node JS to do a insert in a MySql Database.

I checked the results of the INSERT and everything went well.

I am using at the result of the query, the var resultId to check the last id inserted on the database, but at this case I am inserting multiple rows into the database and my resultId has the value of the first inserted one.

Do in node Js exist something to use that I can see all the inserted resultId's ?

Thank you

Upvotes: 5

Views: 1772

Answers (1)

mscdex
mscdex

Reputation: 106696

You can only get the ID for the first inserted row. If the primary key column is auto-incrementing, you could just increment the last insert ID to compute the inserted IDs for the second, third, etc. rows.

Upvotes: 4

Related Questions