2023-10-02 16:02:31 -04:00
|
|
|
import mongoose, {
|
|
|
|
Schema,
|
|
|
|
connect,
|
|
|
|
PopulatedDoc,
|
|
|
|
Document,
|
|
|
|
Model,
|
|
|
|
} from "mongoose";
|
|
|
|
import SequenceFactory from "mongoose-sequence";
|
|
|
|
|
|
|
|
import { IPrivMsg } from "./privMsg";
|
2023-10-02 16:06:01 -04:00
|
|
|
import { IUser } from "./user";
|
2023-10-02 16:02:31 -04:00
|
|
|
export interface IInbox {
|
2023-10-02 16:06:01 -04:00
|
|
|
owningUser: PopulatedDoc<IUser & Document>;
|
2023-10-02 16:02:31 -04:00
|
|
|
saved: PopulatedDoc<IPrivMsg & Document>[];
|
|
|
|
received: PopulatedDoc<IPrivMsg & Document>[];
|
|
|
|
sent: PopulatedDoc<IPrivMsg & Document>[];
|
|
|
|
}
|
|
|
|
|
|
|
|
const InboxSchema = new Schema<IInbox>({
|
2023-10-02 16:06:01 -04:00
|
|
|
owningUser: {
|
2023-10-02 16:02:31 -04:00
|
|
|
type: Number,
|
2023-10-02 16:06:01 -04:00
|
|
|
ref: "User",
|
2023-10-02 16:02:31 -04:00
|
|
|
},
|
|
|
|
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",
|
|
|
|
);
|