39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
const { Category } = require('../models');
|
|
|
|
async function checkCategoryIds() {
|
|
try {
|
|
console.log('\n=== Checking Category IDs ===\n');
|
|
|
|
const categories = await Category.findAll({
|
|
attributes: ['id', 'name', 'isActive', 'guestAccessible'],
|
|
limit: 10
|
|
});
|
|
|
|
console.log(`Found ${categories.length} categories:\n`);
|
|
|
|
categories.forEach(cat => {
|
|
console.log(`ID: ${cat.id} (${typeof cat.id})`);
|
|
console.log(` Name: ${cat.name}`);
|
|
console.log(` isActive: ${cat.isActive}`);
|
|
console.log(` guestAccessible: ${cat.guestAccessible}`);
|
|
console.log('');
|
|
});
|
|
|
|
// Try to find one by PK
|
|
if (categories.length > 0) {
|
|
const firstId = categories[0].id;
|
|
console.log(`\nTrying findByPk with ID: ${firstId} (${typeof firstId})\n`);
|
|
|
|
const found = await Category.findByPk(firstId);
|
|
console.log('findByPk result:', found ? found.name : 'NOT FOUND');
|
|
}
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
checkCategoryIds();
|