[当从节点js在MySQL中使用'SELECT'命令时。有时查询返回非null值,有时返回带有相同查询的null
这是我的代码:
exports.Top10 = functions.https.onRequest(function (req, res) {
connection.query("SELECT * FROM Ads ORDER BY (Stars / Raters) LIMIT 10", function (err, result) {
if (err) {
console.log("Top10 Err: ", err);
}
res.end(JSON.stringify(result));
});
});
Top10错误:{错误:致命错误后无法使查询入队。
at Protocol._validateEnqueue (/user_code/node_modules/mysql/lib/protocol/Protocol.js:201:16) at Protocol._enqueue (/user_code/node_modules/mysql/lib/protocol/Protocol.js:139:13) at Connection.query (/user_code/node_modules/mysql/lib/Connection.js:208:25) at /user_code/index.js:510:28 at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:41) at /var/tmp/worker/worker.js:671:7 at /var/tmp/worker/worker.js:655:9 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickDomainCallback (internal/process/next_tick.js:128:9) code:
'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR',致命:否}
我将Firebase
云功能用作节点服务器,并将Amazon RDS MySQL
用于数据库
如果对此问题有任何疑问,请发表评论
当用于订购然后应用于desc / asc时,将使用此代码
exports.Top10 = functions.https.onRequest(function (req, res) {
connection.query("SELECT * FROM Ads ORDER BY (Stars / Raters) DESC LIMIT 10", function (err, result) {
if (err) {
console.log("Top10 Err: ", err);
}
res.end(JSON.Parse(result));
});
});