feat(db/models): create dedicated private message inbox model
This commit is contained in:
parent
63dd3d063a
commit
38516dc80d
46
models/inbox.ts
Normal file
46
models/inbox.ts
Normal file
@ -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<IPrivMsg & Document>[];
|
||||||
|
received: PopulatedDoc<IPrivMsg & Document>[];
|
||||||
|
sent: PopulatedDoc<IPrivMsg & Document>[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const InboxSchema = new Schema<IInbox>({
|
||||||
|
_id: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
saved: [
|
||||||
|
{
|
||||||
|
type: Number,
|
||||||
|
ref: "PrivMsg",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
received: [
|
||||||
|
{
|
||||||
|
type: Number,
|
||||||
|
ref: "PrivMsg",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sent: [
|
||||||
|
{
|
||||||
|
type: Number,
|
||||||
|
ref: "PrivMsg",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const Inbox: Model<IInbox> = mongoose.model<IInbox>(
|
||||||
|
"Inbox",
|
||||||
|
InboxSchema,
|
||||||
|
"inboxes",
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user