https://github.com/mysqljs/mysql #getting-the-id-of-an-inserted-row menjelaskan solusinya dengan sangat baik:
connection.query('INSERT INTO posts SET ?', {title: 'test'}, function(err, result, fields) {
if (err) throw err;
console.log(result.insertId);
});