49 lines
796 B
TypeScript
49 lines
796 B
TypeScript
import mongoose, {
|
|
Schema,
|
|
connect,
|
|
PopulatedDoc,
|
|
Document,
|
|
Model,
|
|
} from "mongoose";
|
|
import SequenceFactory from "mongoose-sequence";
|
|
|
|
import { IPrivMsg } from "./privMsg";
|
|
import { IUser } from "./user";
|
|
export interface IInbox {
|
|
owningUser: PopulatedDoc<IUser & Document>;
|
|
saved: PopulatedDoc<IPrivMsg & Document>[];
|
|
received: PopulatedDoc<IPrivMsg & Document>[];
|
|
sent: PopulatedDoc<IPrivMsg & Document>[];
|
|
}
|
|
|
|
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",
|
|
},
|
|
],
|
|
});
|
|
|
|
export const Inbox: Model<IInbox> = mongoose.model<IInbox>(
|
|
"Inbox",
|
|
InboxSchema,
|
|
"inboxes",
|
|
);
|