How does nodejs synchronize query data

  node.js, question

Query database to return data

javascriptfunction get_result(mac, callback) {
 db.query('SELECT device_id from terminal_device WHERE mac=?'  , [mac], function (err, rows) {
 if (err) {
 return callback(err, rows);
 bracket
 callback(null, rows);
 });
 };

Call the above method

javascriptvar result = get_result('30-3A-64-91-52-01', function (err, rows) {
 Log (rows [0] [0] plus "\t1")
 return rows[0][0];
 })
 Log (result plus "\t2")

The current problem: the log output by calling method inside has a result and the value is correct, but the log 2 input is undefined and does not know how to solve it. It should be nodejs asynchronous problem, but does not know how to solve it.

promise