42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const { Category } = require('./models');
|
|
|
|
async function getCategoryMapping() {
|
|
try {
|
|
const categories = await Category.findAll({
|
|
where: { isActive: true },
|
|
attributes: ['id', 'name', 'slug', 'guestAccessible'],
|
|
order: [['displayOrder', 'ASC']]
|
|
});
|
|
|
|
console.log('\n=== Category ID Mapping ===\n');
|
|
|
|
const mapping = {};
|
|
categories.forEach(cat => {
|
|
mapping[cat.slug] = {
|
|
id: cat.id,
|
|
name: cat.name,
|
|
guestAccessible: cat.guestAccessible
|
|
};
|
|
console.log(`${cat.name} (${cat.slug})`);
|
|
console.log(` ID: ${cat.id}`);
|
|
console.log(` Guest Accessible: ${cat.guestAccessible}`);
|
|
console.log('');
|
|
});
|
|
|
|
// Export for use in tests
|
|
console.log('\nFor tests, use:');
|
|
console.log('const CATEGORY_IDS = {');
|
|
Object.keys(mapping).forEach(slug => {
|
|
console.log(` ${slug.toUpperCase().replace(/-/g, '_')}: '${mapping[slug].id}',`);
|
|
});
|
|
console.log('};');
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
getCategoryMapping();
|