Return empty array or error
问题 I have nodejs accessing a database to retrieve a row of orders. The following function is defined in a file called orderDb.js module.exports.getWaitingOrders = function getWaitingOrders(callback) { pool.query("SELECT * FROM live_order_table WHERE isWaiting = 1;", function(err, rows, fields) { if (err) { return new Error('Db error: ' + err); } if (rows.length <= 0) { return new Error("No results"); //Is this recommended? return [];// or this? } rows.forEach(function(row) { var order = {