"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BorrowerModel = exports.BorrowerSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const mongooseLeanId = require('gemcap-be-common/plugins/id.plugin');
exports.BorrowerSchema = new mongoose_1.default.Schema({
    code: {
        type: String,
        trim: true,
        required: true,
    },
    name: {
        type: String,
        trim: true,
        required: true,
    },
    title: {
        type: String,
        trim: true,
        required: true,
    },
    active: {
        type: Boolean,
        default: true,
    },
    accrualStatus: {
        type: Boolean,
        default: false,
    },
    organizationId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.organizations,
    },
    schemas: {
        required: false,
        type: [
            {
                name: {
                    type: String,
                    trim: true,
                    required: true,
                },
                type: {
                    type: String,
                    trim: true,
                    required: true,
                },
                data: [
                    {
                        column: {
                            type: String,
                            trim: true,
                            required: true,
                        },
                        databaseTitle: {
                            type: String,
                            trim: true,
                            required: true,
                        },
                    },
                ],
            },
        ],
        default: [],
    },
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.BorrowerSchema.pre(/^(save)/, async function () {
});
exports.BorrowerSchema.pre(/^(updateOne|updateMany|findOneAndUpdate)/, async function () {
});
exports.BorrowerSchema.pre(/^(findOneAndDelete|deleteOne|deleteMany)/, async function () {
});
exports.BorrowerSchema.plugin(mongooseLeanId);
exports.BorrowerModel = mongoose_1.default.model(_models_1.MODEL_NAMES.borrowers, exports.BorrowerSchema);
