38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import { sequelize } from '../utils/sequelize.js';
|
|
import PromotionalGift from '../models/falukant/type/promotional_gift.js';
|
|
import PromotionalGiftMood from '../models/falukant/predefine/promotional_gift_mood.js';
|
|
import PromotionalGiftCharacterTrait from '../models/falukant/predefine/promotional_gift_character_trait.js';
|
|
|
|
async function dump() {
|
|
try {
|
|
await sequelize.authenticate();
|
|
console.log('DB connected');
|
|
|
|
const gifts = await PromotionalGift.findAll({
|
|
include: [
|
|
{ model: PromotionalGiftMood, as: 'promotionalgiftmoods', attributes: ['moodId', 'suitability'], required: false },
|
|
{ model: PromotionalGiftCharacterTrait, as: 'characterTraits', attributes: ['traitId', 'suitability'], required: false }
|
|
]
|
|
});
|
|
|
|
console.log(`found ${gifts.length} gifts`);
|
|
for (const g of gifts) {
|
|
console.log('---');
|
|
console.log('id:', g.id, 'name:', g.name, 'raw value type:', typeof g.value, 'value:', g.value);
|
|
try {
|
|
const plain = g.get({ plain: true });
|
|
console.log('plain value:', JSON.stringify(plain));
|
|
} catch (e) {
|
|
console.log('could not stringify plain', e);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error('dump failed', err);
|
|
process.exit(2);
|
|
} finally {
|
|
await sequelize.close();
|
|
}
|
|
}
|
|
|
|
dump();
|