49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
|
|
import dotenv from 'dotenv';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
dotenv.config({ path: path.join(__dirname, '../.env') });
|
|
|
|
import db from '../src/database/models/index.js';
|
|
|
|
async function run() {
|
|
try {
|
|
const app = await db.Application.findOne({
|
|
order: [['updatedAt', 'DESC']],
|
|
include: [
|
|
{ model: db.District, as: 'district' },
|
|
{
|
|
model: db.RequestParticipant,
|
|
as: 'participants',
|
|
include: [{ model: db.User, as: 'user' }]
|
|
}
|
|
]
|
|
});
|
|
|
|
if (!app) {
|
|
console.log('No applications found');
|
|
return;
|
|
}
|
|
|
|
console.log('Application ID:', app.id);
|
|
console.log('Status:', app.status);
|
|
console.log('District:', app.district?.name);
|
|
console.log('District ddAmId:', app.district?.ddAmId);
|
|
console.log('District asmId:', app.district?.asmId);
|
|
|
|
console.log('Participants:');
|
|
app.participants?.forEach(p => {
|
|
console.log(`- ${p.user?.fullName} (${p.metadata?.role})`);
|
|
});
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
run();
|