Dealer_Onboarding_Backend/scripts/test-areas.ts

22 lines
680 B
TypeScript

import db from '../src/database/models/index.js';
const { Area, District, User } = db;
async function testAreas() {
try {
console.log('Testing Area.findAll...');
const areas = await Area.findAll({
include: [
{ model: District, as: 'district', attributes: ['districtName'] },
{ model: User, as: 'manager', attributes: ['id', 'fullName', 'email', 'mobileNumber'] }
],
order: [['areaName', 'ASC']]
});
console.log('Successfully fetched areas:', JSON.stringify(areas, null, 2));
} catch (error) {
console.error('Error fetching areas:', error);
}
}
testAreas();