Categories
express mysql node.js

connection.query(…).then is not a function

I am new to the node js . I am using node with express in my backend and mysql as database . I have the confusion while handling the async calling . In my code while i use .

return connection.query(qry).then(
function(result) {
console.log('Query executed');
resolve(result.rows[0]);
},
function(err) {
console.log('Error occurred', err);
reject(err);
}
)

I got error connection.query(…).then is not a function

connection.query(qry, function (err, rows, fields) {
});

is executed correctly.
Simple query i am not getting any problem . while execute the complex query the above one is not wait for complete query execution