Skip to content

Commit 47ba7bb

Browse files
authored
Merge pull request #39 from hack4impact-calpoly/issue29-notification-schema
notification schema ts created
2 parents 442481c + 977027b commit 47ba7bb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/database/notificationSchema.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import mongoose, { Schema } from "mongoose";
2+
3+
export type INotification = {
4+
_id: string;
5+
description: string;
6+
userId: string;
7+
time: Date;
8+
};
9+
10+
const notificationSchema = new Schema(
11+
{
12+
description: { type: String, required: true },
13+
userId: { type: String, required: true },
14+
time: { type: Date, required: true, default: Date.now },
15+
},
16+
{
17+
collection: "notifications",
18+
},
19+
);
20+
21+
const NotificationModel =
22+
mongoose.models.Notification || mongoose.model<INotification>("Notification", notificationSchema);
23+
24+
export default NotificationModel;

0 commit comments

Comments
 (0)