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(); } })();