import mongoConnection from "$connections/mongo/mongo.connection.js";

import mongoose from "mongoose";

const mongooseSchema = mongoose.Schema;

export const schemaModel = {
  name: {
    type: String,
    required: true,
    trim: true,
    index: true,
  },
  bankCode: {
    type: String,
    required: true,
    unique: true,
    trim: true,
    index: true,
  },
  sejamBankId: {
    type: String,
    required: true,
    unique: true,
    trim: true,
    index: true,
  },
};

export const schema = new mongooseSchema(schemaModel, { timestamps: true });

schema.index({ name: "text", bankCode: "text", sejamBankId: "text" });

export default mongoConnection.model("Bank", schema);
