Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // call function
- myQuery(1)
- .then((queryData)=>{
- console.log(queryData);
- })
- .catch((error)=>{
- console.log(error);
- });
- // query function
- myQuery(account_id){
- return new Promise( (resolve, reject) => {
- const sql = "SELECT * FROM user WHERE account_id = ?";
- this.db_connection.query(sql, [account_id], function(error, rows) {
- if (error)
- {
- const error = error.stack;
- reject(error);
- }
- if(rows.length === 0){
- reject('user is not exist');
- }else{ // user is exist
- resolve(rows);
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement