modified: server.js

This commit is contained in:
IrisVega 2024-07-20 17:10:22 +08:00
parent 763a9a1da6
commit d27b061fe4

View File

@ -53,7 +53,7 @@ function getSensorData(callback) {
// 获取数据库中最新的数据 // 获取数据库中最新的数据
function getLatestSensorData(callback) { function getLatestSensorData(callback) {
const sql = 'SELECT temperature, humidity, co2, pressure FROM sensor_data ORDER BY timestamp DESC LIMIT 1'; const sql = 'SELECT temperature, humidity, co2, pressure timestamp FROM sensor_data ORDER BY id DESC LIMIT 1';
db.query(sql, (err, results) => { db.query(sql, (err, results) => {
if (err) { if (err) {
console.error('Error fetching latest sensor data: ', err); console.error('Error fetching latest sensor data: ', err);