32 lines
923 B
JavaScript
32 lines
923 B
JavaScript
const { LoanProduct } = require('./models');
|
|
|
|
async function checkData() {
|
|
try {
|
|
console.log('检查数据库中的贷款商品数据...');
|
|
|
|
const count = await LoanProduct.count();
|
|
console.log(`数据库中共有 ${count} 条贷款商品数据`);
|
|
|
|
if (count > 0) {
|
|
const products = await LoanProduct.findAll({
|
|
limit: 3,
|
|
attributes: ['id', 'productName', 'loanAmount', 'loanTerm', 'interestRate', 'onSaleStatus']
|
|
});
|
|
|
|
console.log('前3条数据:');
|
|
products.forEach((product, index) => {
|
|
console.log(`${index + 1}. ID: ${product.id}, 名称: ${product.productName}, 额度: ${product.loanAmount}`);
|
|
});
|
|
} else {
|
|
console.log('数据库中没有贷款商品数据,需要添加测试数据');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('检查数据失败:', error);
|
|
} finally {
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
checkData();
|