35 lines
946 B
TypeScript
35 lines
946 B
TypeScript
// src/models/email-log.ts
|
|
// Copyright (C) 2026 Robert Colbert <rob.colbert@openplatform.us>
|
|
// All Rights Reserved
|
|
|
|
import { Schema, model } from "mongoose";
|
|
|
|
import { GadgetId } from "@gadget/api";
|
|
import { nanoid } from "nanoid";
|
|
|
|
export interface IEmailLog {
|
|
_id: GadgetId;
|
|
created: Date;
|
|
from: string;
|
|
to: string;
|
|
to_lc: string;
|
|
subject: string;
|
|
messageId: string;
|
|
}
|
|
export const EmailLogSchema = new Schema<IEmailLog>({
|
|
_id: { type: String, default: () => nanoid() },
|
|
created: { type: Date, default: Date.now, required: true, index: -1 },
|
|
from: { type: String, required: true },
|
|
to: { type: String, required: true },
|
|
to_lc: { type: String, required: true, lowercase: true, index: 1 },
|
|
subject: { type: String, required: true },
|
|
messageId: { type: String },
|
|
});
|
|
|
|
export const EmailLog = model<IEmailLog>("EmailLog", EmailLogSchema);
|
|
export default EmailLog;
|
|
|
|
(async () => {
|
|
await EmailLog.syncIndexes();
|
|
})();
|