add changes
This commit is contained in:
40
backend/tests/test-find-by-pk.js
Normal file
40
backend/tests/test-find-by-pk.js
Normal file
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user