41 lines
917 B
JavaScript
41 lines
917 B
JavaScript
const { Category } = require('./models');
|
|
|
|
async function testFindByPk() {
|
|
try {
|
|
console.log('\n=== Testing Category.findByPk(1) ===\n');
|
|
|
|
const category = await Category.findByPk(1, {
|
|
attributes: [
|
|
'id',
|
|
'name',
|
|
'slug',
|
|
'description',
|
|
'icon',
|
|
'color',
|
|
'questionCount',
|
|
'displayOrder',
|
|
'guestAccessible',
|
|
'isActive'
|
|
]
|
|
});
|
|
|
|
console.log('Result:', JSON.stringify(category, null, 2));
|
|
|
|
if (category) {
|
|
console.log('\nCategory found:');
|
|
console.log(' Name:', category.name);
|
|
console.log(' isActive:', category.isActive);
|
|
console.log(' guestAccessible:', category.guestAccessible);
|
|
} else {
|
|
console.log('Category not found!');
|
|
}
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testFindByPk();
|