const { sequelize, Project, User } = require('./models'); (async () => { try { console.log('DB should be ningxia_bank test:'); const [dbRow] = await sequelize.query('SELECT DATABASE() AS db'); console.log('DB:', dbRow[0].db); console.log('Testing Project.findAndCountAll with includes...'); const result = await Project.findAndCountAll({ include: [ { model: User, as: 'creator', attributes: ['id', 'username'] }, { model: User, as: 'updater', attributes: ['id', 'username'] } ], limit: 5 }); console.log('count:', result.count); console.log('rows length:', result.rows.length); } catch (err) { console.error('ERROR:', err.message); } finally { await sequelize.close(); } })();