const prisma = require('../../prisma/PrismaClient.js');

const AreaRepository = {
    findAll: async ({ skip, take, where, orderBy }) => {
        return await prisma.userArea.findMany({
            where,
            skip,
            take,
            orderBy,
            select: {
                id: true,
                user: {
                    select: {
                        id: true,
                        username: true
                    }
                },
                province: {
                    select: {
                        id: true,
                        name: true
                    }
                },
            }
        });
    },

    countAll: async (where) => {
        return prisma.userArea.count({ where });
    },
};

module.exports = AreaRepository;