Initial commit: 宁夏智慧养殖监管平台
This commit is contained in:
23
backend/check-devices.js
Normal file
23
backend/check-devices.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { Device } = require('./models');
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const devices = await Device.findAll({
|
||||
limit: 5,
|
||||
attributes: ['id', 'name', 'type']
|
||||
});
|
||||
|
||||
console.log('前5个设备:');
|
||||
devices.forEach(d => {
|
||||
console.log(`ID: ${d.id}, 名称: ${d.name}, 类型: ${d.type}`);
|
||||
});
|
||||
|
||||
const totalCount = await Device.count();
|
||||
console.log(`\n设备总数: ${totalCount}`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('检查设备时出错:', error);
|
||||
} finally {
|
||||
process.exit();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user