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 6 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
23 changes: 23 additions & 0 deletions server/schemas/admin.schema.ts
Original file line number Diff line number Diff line change
@@ -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;
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 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;
27 changes: 27 additions & 0 deletions server/schemas/mess.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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: {
type: String,
unique: true,
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
},
rating: Number,
batch: {
type: String,
enum: batches,
},
hostelName: [String],
Albert-2 marked this conversation as resolved.
Show resolved Hide resolved
});

export const Mess = mongoose.model("Mess", messSchema);
export type Mess = typeof Mess;
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 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;
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 UserDetail = mongoose.model("UserDetail", userDetailSchema);
export type UserDetail = typeof UserDetail;
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 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;
9 changes: 8 additions & 1 deletion server/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ const batches = [

const genders = ["MALE", "FEMALE"];

export { batches, genders };
const accesses = [
"GetMessList",
"GetMessUnallottedUsers",
"OpenOrCloseMessRegistration",
"MessAllotment",
];

export { batches, genders, accesses };
2 changes: 1 addition & 1 deletion yarn.lock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a change in yarn.lock? Revert this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -7547,4 +7547,4 @@ __metadata:
resolution: "yocto-queue@npm:0.1.0"
checksum: dceb44c28578b31641e13695d200d34ec4ab3966a5729814d5445b194933c096b7ced71494ce53a0e8820685d1d010df8b2422e5bf2cdea7e469d97ffbea306f
languageName: node
linkType: hard
linkType: hard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully revert this file. It shows some whitespace changes