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 5 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
27 changes: 27 additions & 0 deletions server/schemas/admin.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import mongoose from "mongoose";

const adminsSchema = new mongoose.Schema({
webmail: {
type: String,
unique: true,
},
description: String,
isStudent: {
type: Boolean,
default: false,
},
accesses: [
{
type: String,
enum: [
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
"GetMessList",
"GetMessUnallottedUsers",
"OpenOrCloseMessRegistration",
"MessAllotment",
],
},
],
});

export const Admins = mongoose.model("Admins", adminsSchema);
export type Admins = typeof Admins;
17 changes: 17 additions & 0 deletions server/schemas/constant.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import mongoose from "mongoose";

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

export const Constants = mongoose.model("Constants", constantsSchema);
export type Constants = typeof Constants;
23 changes: 23 additions & 0 deletions server/schemas/mess.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import mongoose from "mongoose";

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

export const Messes = mongoose.model("Messes", messesSchema);
export type Messes = typeof Messes;
18 changes: 18 additions & 0 deletions server/schemas/messReview.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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);
export type MessReviews = typeof MessReviews;
15 changes: 15 additions & 0 deletions server/schemas/userDetail.schema.ts
Original file line number Diff line number Diff line change
@@ -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 UserDetails = mongoose.model("UserDetails", userDetailSchema);
export type UserDetails = typeof UserDetails;
22 changes: 22 additions & 0 deletions server/schemas/userMessDetail.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
);
export type UserMessDetails = typeof UserMessDetails;
Loading