-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailListModel.ts
More file actions
24 lines (20 loc) · 786 Bytes
/
mailListModel.ts
File metadata and controls
24 lines (20 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import mongoose, { Schema, Document, Model } from "mongoose";
import { v4 as uuidv4 } from "uuid";
export interface IMailRecipient extends Document {
uuid: string;
name: string;
email: string;
createdAt?: Date;
updatedAt?: Date;
}
const MailRecipientSchema = new Schema<IMailRecipient>(
{
uuid: { type: String, required: true, unique: true, default: () => uuidv4(), index: true },
name: { type: String, required: true, trim: true },
email: { type: String, required: true, trim: true, lowercase: true, unique: true, index: true },
},
{ timestamps: true }
);
const MailListModel: Model<IMailRecipient> = (mongoose.models.MailList as Model<IMailRecipient>) ||
mongoose.model<IMailRecipient>("MailList", MailRecipientSchema);
export default MailListModel;