Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data models #4

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions server/models/access.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import mongoose from "mongoose";

const accessSchema = new mongoose.Schema({
value: {
type: String,
enum: [
"GetMessList",
"GetMessUnallottedUsers",
"OpenOrCloseMessRegistration",
"MessAllotment",
],
required: true,
unique: true,
},
});

export const Access = mongoose.model("Access", accessSchema);
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 18 additions & 0 deletions server/models/admins.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import mongoose from "mongoose";

const adminsSchema = new mongoose.Schema({
webmail: {
type: String,
unique: true,
},
description: String,
isStudent: Boolean,
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
accesses: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Access",
},
],
});

export const Admins = mongoose.model("Admins", adminsSchema);
13 changes: 13 additions & 0 deletions server/models/constants.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import mongoose from "mongoose";

const constantsSchema = new mongoose.Schema({
constKey: {
type: String,
unique: true,
},
description: String,
type: String,
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
value: mongoose.Schema.Types.Mixed,
});

export const Constants = mongoose.model("Constants", constantsSchema);
12 changes: 12 additions & 0 deletions server/models/gender.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import mongoose from "mongoose";
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved

const genderScheme = new mongoose.Schema({
value: {
type: String,
enum: ["Male", "Female"],
required: true,
unique: true,
},
});

export const Gender = mongoose.model("Gender", genderScheme);
17 changes: 17 additions & 0 deletions server/models/messReviews.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import mongoose from "mongoose";

const messReviewsSchema = 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 MessReviews = mongoose.model("MessReviews", messReviewsSchema);
19 changes: 19 additions & 0 deletions server/models/messes.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import mongoose from "mongoose";

const messesSchema = new mongoose.Schema({
messName: {
type: String,
unique: true,
},
population: Number,
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
capacity: Number,
location: {
type: String,
unique: true,
},
rating: Number,
batches: [String],
hostelNames: [String],
});

export const Messes = mongoose.model("Messes", messesSchema);
14 changes: 14 additions & 0 deletions server/models/userDetails.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import mongoose from "mongoose";

const userDetailSchema = new mongoose.Schema({
rollNumber: {
type: Number,
required: true,
unique: true,
},
name: Number,
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
hostelName: String,
roomNumber: Number,
});

export const UserDetails = mongoose.model("UserDetails", userDetailSchema);
21 changes: 21 additions & 0 deletions server/models/userMessDetails.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import mongoose from "mongoose";

const userMessDetailsSchema = 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 UserMessDetails = mongoose.model(
"UserMessDetails",
userMessDetailsSchema
);
20 changes: 20 additions & 0 deletions server/models/users.models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import mongoose from "mongoose";
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved

const usersSchema = new mongoose.Schema({
rollNumber: {
type: Number,
required: true,
unique: true,
},
gender: {
type: mongoose.Schema.Types.ObjectId,
ref: "Gender",
},
batch: String,
messDetailsID: {
type: mongoose.Schema.Types.ObjectId,
ref: "UserMessDetails",
},
});

export const User = mongoose.model("User", usersSchema);
Loading