import { Model } from "mongoose"; import { MongooseModule, } from "../helpers"; import { SMSLogType } from "../types/sms-log"; export interface SMSLog extends SMSLogType { } export default async function SMSLogModule(mongoose: MongooseModule) { const { Schema } = mongoose; const modelSchema = new Schema({ _id: { type: Schema.Types.ObjectId, auto: true, }, accountId: { type: String, default: "" }, messageId: { type: String, default: "", }, status: { type: String, default: "", }, createdAt: { type: Date, }, sentAt: { type: Date, }, from: { type: String, default: "", }, to: { type: String, default: "", }, errorCode: { type: String, default: "", }, errorMessage: { type: String, default: "", }, }, { autoIndex: false, }); modelSchema.index({ status: 1, }, { name: "status_1", }); return mongoose.model("SMSLog", modelSchema, "massive_sms_log", { overwriteModels: true }); } export interface SMSLogModel extends Model { }