next/models/inbox.ts

38 lines
672 B
TypeScript
Raw Normal View History

2023-12-29 20:11:07 -05:00
import mongoose, { Schema, PopulatedDoc, Model } from "mongoose";
import { IPrivMsg } from "./privMsg";
import { IUser } from "./user";
export interface IInbox {
owningUser: PopulatedDoc<IUser>;
saved: PopulatedDoc<IPrivMsg>[];
received: PopulatedDoc<IPrivMsg>[];
sent: PopulatedDoc<IPrivMsg>[];
}
const InboxSchema = new Schema<IInbox>({
owningUser: {
type: Number,
ref: "User",
},
saved: [
{
type: Number,
ref: "PrivMsg",
},
],
received: [
{
type: Number,
ref: "PrivMsg",
},
],
sent: [
{
type: Number,
ref: "PrivMsg",
},
],
});
2023-12-29 20:11:07 -05:00
export const Inbox: Model<IInbox> = mongoose.model<IInbox>("Inbox", InboxSchema, "inboxes");