
import db from '../src/database/models/index.js';
const { Region, Zone, State, User } = db;

async function testRegions() {
    try {
        console.log('Testing Region.findAll...');
        const regions = await Region.findAll({
            include: [
                {
                    model: State,
                    as: 'states',
                    attributes: ['id', 'stateName']
                },
                {
                    model: Zone,
                    as: 'zone',
                    attributes: ['id', 'zoneName']
                },
                {
                    model: User,
                    as: 'regionalManager',
                    attributes: ['id', 'fullName', 'email', 'mobileNumber']
                }
            ],
            order: [['regionName', 'ASC']]
        });
        console.log('Successfully fetched regions:', JSON.stringify(regions, null, 2));
    } catch (error) {
        console.error('Error fetching regions:', error);
    }
}

testRegions();
