Look at the insert function in this library: https://github.com/mvolkmann/mysql-easier/blob/master/src/sql-util.js The trick is to “select last_insert_id()” after the insert. You could also just use mysql-easier from your Node app. That’s what I do. https://www.npmjs.com/package/mysql-easier
--- R. Mark Volkmann Object Computing, Inc. > On Jan 23, 2018, at 6:08 AM, Mat Klik <[email protected]> wrote: > > Hi All, > > As someone who is currently learning nodejs I've ran into a small issue and > I'm now hitting my head against a wall. > > I'm successfully on a POST request checking if a user exists and then > inserting a new record against their account based on their ID. > > Where I'm failing down is I can't retrieve the last inserted ID after new > record creation. Documentation says to use: .insertId this returns 0 on every > instance. > > Could someone please give me a few pointers in the right direction? > > Much appreciated. > > Mat > -- > Job board: http://jobs.nodejs.org/ > New group rules: > https://gist.github.com/othiym23/9886289#file-moderation-policy-md > Old group rules: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/2b30903b-7061-49d5-8087-9510c723a55c%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/9DA66597-FD73-435F-90F7-8AEF52C5EB9E%40gmail.com. For more options, visit https://groups.google.com/d/optout.
