diff --git a/server/schemas/admin.schema.ts b/server/schemas/admin.schema.ts new file mode 100644 index 0000000..36eb8eb --- /dev/null +++ b/server/schemas/admin.schema.ts @@ -0,0 +1,23 @@ +import mongoose from "mongoose"; +import { accesses } from "../utils/constants"; + +const adminSchema = new mongoose.Schema({ + webmail: { + type: String, + unique: true, + }, + description: String, + isStudent: { + type: Boolean, + default: false, + }, + access: [ + { + type: String, + enum: accesses, + }, + ], +}); + +export const Admin = mongoose.model("Admin", adminSchema); +export type Admin = typeof Admin; diff --git a/server/schemas/constant.schema.ts b/server/schemas/constant.schema.ts new file mode 100644 index 0000000..2a14046 --- /dev/null +++ b/server/schemas/constant.schema.ts @@ -0,0 +1,17 @@ +import mongoose from "mongoose"; + +const constantSchema = new mongoose.Schema({ + constKey: { + type: String, + unique: true, + }, + description: String, + type: { + type: String, + enum: ["Number", "String", "Object", "Array"], + }, + value: mongoose.Schema.Types.Mixed, +}); + +export const Constant = mongoose.model("Constant", constantSchema); +export type Constant = typeof Constant; diff --git a/server/schemas/mess.schema.ts b/server/schemas/mess.schema.ts new file mode 100644 index 0000000..395c46e --- /dev/null +++ b/server/schemas/mess.schema.ts @@ -0,0 +1,24 @@ +import mongoose from "mongoose"; +import { batches } from "../utils/constants"; + +const messSchema = new mongoose.Schema({ + messName: { + type: String, + unique: true, + }, + population: { + type: Number, + default: 0, + }, + capacity: Number, + location: [String], + rating: Number, + batch: { + type: String, + enum: batches, + }, + hostelNames: [String], +}); + +export const Mess = mongoose.model("Mess", messSchema); +export type Mess = typeof Mess; diff --git a/server/schemas/messReview.schema.ts b/server/schemas/messReview.schema.ts new file mode 100644 index 0000000..3cc4913 --- /dev/null +++ b/server/schemas/messReview.schema.ts @@ -0,0 +1,18 @@ +import mongoose from "mongoose"; + +const messReviewSchema = new mongoose.Schema({ + messID: { + type: mongoose.Schema.Types.ObjectId, + ref: "Mess", + }, + userID: { + type: mongoose.Schema.Types.ObjectId, + ref: "User", + }, + comment: String, + rating: Number, + time: Date, +}); + +export const MessReview = mongoose.model("MessReview", messReviewSchema); +export type MessReview = typeof MessReview; diff --git a/server/schemas/userDetail.schema.ts b/server/schemas/userDetail.schema.ts new file mode 100644 index 0000000..8aea436 --- /dev/null +++ b/server/schemas/userDetail.schema.ts @@ -0,0 +1,15 @@ +import mongoose from "mongoose"; + +const userDetailSchema = new mongoose.Schema({ + rollNumber: { + type: Number, + required: true, + unique: true, + }, + name: String, + hostelName: String, + roomNumber: Number, +}); + +export const UserDetail = mongoose.model("UserDetail", userDetailSchema); +export type UserDetail = typeof UserDetail; diff --git a/server/schemas/userMessDetail.schema.ts b/server/schemas/userMessDetail.schema.ts new file mode 100644 index 0000000..02b692f --- /dev/null +++ b/server/schemas/userMessDetail.schema.ts @@ -0,0 +1,22 @@ +import mongoose from "mongoose"; + +const userMessDetailSchema = new mongoose.Schema({ + messID: { + type: mongoose.Schema.Types.ObjectId, + ref: "Mess", + }, + messPreference: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Mess", + }, + ], + messRegistrationTime: Date, + isEligibleForRegistering: Boolean, +}); + +export const UserMessDetail = mongoose.model( + "UserMessDetail", + userMessDetailSchema +); +export type UserMessDetail = typeof UserMessDetail; diff --git a/server/utils/constants.ts b/server/utils/constants.ts index 96a0b33..46135b8 100644 --- a/server/utils/constants.ts +++ b/server/utils/constants.ts @@ -26,4 +26,11 @@ const batches = [ const genders = ["MALE", "FEMALE"]; -export { batches, genders }; +const accesses = [ + "GetMessList", + "GetMessUnallottedUsers", + "OpenOrCloseMessRegistration", + "MessAllotment", +]; + +export { batches, genders, accesses };