"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BorrowersDB = void 0;
const Borrower_model_1 = require("../models/Borrower.model");
class BorrowersDB {
    async getAllBorrowers() {
        return Borrower_model_1.BorrowerModel.find().sort({ name: 1 }).lean();
    }
    async getActiveBorrowers() {
        return Borrower_model_1.BorrowerModel.find({ active: true }).sort({ name: 1 }).lean();
    }
    async getAllowedBorrowers(user) {
        return Borrower_model_1.BorrowerModel
            .find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess } })
            .collation({ locale: 'en' })
            .sort({ code: 1 })
            .lean();
    }
}
exports.BorrowersDB = BorrowersDB;
