From 38516dc80de8bd13c897f1d347f3cff3ff809283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Mon, 2 Oct 2023 16:02:31 -0400 Subject: [PATCH] feat(db/models): create dedicated private message inbox model --- models/inbox.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 models/inbox.ts diff --git a/models/inbox.ts b/models/inbox.ts new file mode 100644 index 0000000..2335844 --- /dev/null +++ b/models/inbox.ts @@ -0,0 +1,46 @@ +import mongoose, { + Schema, + connect, + PopulatedDoc, + Document, + Model, +} from "mongoose"; +import SequenceFactory from "mongoose-sequence"; + +import { IPrivMsg } from "./privMsg"; +export interface IInbox { + _id: number; + saved: PopulatedDoc[]; + received: PopulatedDoc[]; + sent: PopulatedDoc[]; +} + +const InboxSchema = new Schema({ + _id: { + type: Number, + }, + saved: [ + { + type: Number, + ref: "PrivMsg", + }, + ], + received: [ + { + type: Number, + ref: "PrivMsg", + }, + ], + sent: [ + { + type: Number, + ref: "PrivMsg", + }, + ], +}); + +export const Inbox: Model = mongoose.model( + "Inbox", + InboxSchema, + "inboxes", +);