Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

mysql - return result of the sql query in node js

I am running this following register user function in my node js web app. I need to get the result of the query to out from the con.connection() function. is there a way to do it in javascript to return a value from an asynchronous function.

const con=require('../connection');

class User{

static async registerUser(NIC,first_name, middle_name, last_name, email,state, address_no,street, phone_number, user_name, password)
{
    con.query('insert into Personal_information (NIC, first_name,middle_name, 
               last_name,address_no,street, state,phone_number, email,user_name, password) 
               values (?)',[[NIC, first_name, middle_name, last_name, address_no,street, 
               state,phone_number,email,user_name, password]],function(err,result)
   {
        if(err) throw err
        console.log(result)
   });
}
}

module.exports=User
question from:https://stackoverflow.com/questions/65850229/return-result-of-the-sql-query-in-node-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...