Initial commit
This commit is contained in:
26
src/schemas/Grade.ts
Normal file
26
src/schemas/Grade.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { ObjectId, Schema, model } from "mongoose"
|
||||
|
||||
export interface GradeNote {
|
||||
label: string;
|
||||
weight: number;
|
||||
}
|
||||
|
||||
interface IGrade {
|
||||
grade?: number;
|
||||
date: Date;
|
||||
gradeDate?: Date;
|
||||
room: number;
|
||||
notes?: GradeNote[];
|
||||
tips: string;
|
||||
}
|
||||
|
||||
const gradeSchema = new Schema<IGrade>({
|
||||
grade: Number,
|
||||
date: {type: Date, required: true},
|
||||
gradeDate: Date,
|
||||
room: {type: Number, required: true},
|
||||
notes: [Object],
|
||||
tips: String,
|
||||
})
|
||||
|
||||
export default model("grade", gradeSchema)
|
||||
15
src/schemas/Group.ts
Normal file
15
src/schemas/Group.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ObjectId, Schema, model } from "mongoose"
|
||||
|
||||
interface IGroup {
|
||||
name: string;
|
||||
rooms?: number[];
|
||||
unames?: string[];
|
||||
}
|
||||
|
||||
const groupSchema = new Schema<IGroup>({
|
||||
name: {type: String, required: true},
|
||||
rooms: [Schema.Types.Number],
|
||||
unames: [Schema.Types.String]
|
||||
})
|
||||
|
||||
export default model("group", groupSchema)
|
||||
17
src/schemas/Key.ts
Normal file
17
src/schemas/Key.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { ObjectId, Schema, model } from "mongoose"
|
||||
|
||||
interface IKey {
|
||||
room: string;
|
||||
whom: ObjectId;
|
||||
borrow: Date;
|
||||
tb?: Date;
|
||||
}
|
||||
|
||||
const keySchema = new Schema<IKey>({
|
||||
room: {type: String, required: true},
|
||||
whom: {type: Schema.Types.ObjectId, ref: "logins", required: true},
|
||||
borrow: {type: Date, default: Date.now, required: true},
|
||||
tb: {type: Date}
|
||||
})
|
||||
|
||||
export default model("key", keySchema)
|
||||
39
src/schemas/Menu.ts
Normal file
39
src/schemas/Menu.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import mongoose, { Schema } from "mongoose"
|
||||
|
||||
interface IMenu {
|
||||
sn: {
|
||||
fancy: string[];
|
||||
second: string;
|
||||
};
|
||||
ob: {
|
||||
soup: string;
|
||||
vege: string;
|
||||
meal: string;
|
||||
condiments: string[];
|
||||
drink: string;
|
||||
other: string[];
|
||||
};
|
||||
kol: string;
|
||||
day: Date;
|
||||
dayTitle?: string;
|
||||
}
|
||||
|
||||
const menuSchema = new Schema<IMenu>({
|
||||
sn: {
|
||||
fancy: {type: [String]},
|
||||
second: {type: String, default: ""}
|
||||
},
|
||||
ob: {
|
||||
soup: {type: String, default: ""},
|
||||
vege: {type: String, default: ""},
|
||||
meal: {type: String, default: ""},
|
||||
condiments: {type: [String]},
|
||||
drink: {type: String, default: ""},
|
||||
other: {type: [String]},
|
||||
},
|
||||
kol: {type: String, default: ""},
|
||||
day: {type: Date, required: true},
|
||||
dayTitle: {type: String, default: ""}
|
||||
})
|
||||
|
||||
export default mongoose.model("menu", menuSchema, "menu")
|
||||
19
src/schemas/News.ts
Normal file
19
src/schemas/News.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import mongoose, { Schema } from "mongoose"
|
||||
|
||||
interface INews {
|
||||
content: string;
|
||||
title: string;
|
||||
date: Date;
|
||||
visible?: boolean;
|
||||
pinned?: boolean
|
||||
}
|
||||
|
||||
const newsSchema = new Schema<INews>({
|
||||
content: {type: String, required: true},
|
||||
title: {type: String, required: true},
|
||||
date: {type: Date, requred: true, default: Date.now},
|
||||
visible: {type: Boolean, default: false},
|
||||
pinned: {type: Boolean, default: false}
|
||||
})
|
||||
|
||||
export default mongoose.model("news", newsSchema)
|
||||
23
src/schemas/Notification.ts
Normal file
23
src/schemas/Notification.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import mongoose, { Schema } from "mongoose"
|
||||
|
||||
interface INotification {
|
||||
endpoint: string;
|
||||
keys: {
|
||||
auth: string;
|
||||
p256dh: string;
|
||||
};
|
||||
uname: string
|
||||
expirationTime?: number
|
||||
}
|
||||
|
||||
const notifSchema = new Schema<INotification>({
|
||||
endpoint: {type: String, required: true},
|
||||
keys: {
|
||||
auth: String,
|
||||
p256dh: String,
|
||||
},
|
||||
uname: {type: String, required: true},
|
||||
expirationTime: Number
|
||||
})
|
||||
|
||||
export default mongoose.model("Notification", notifSchema)
|
||||
25
src/schemas/User.ts
Normal file
25
src/schemas/User.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import mongoose, { Schema } from "mongoose"
|
||||
|
||||
// TODO: Unify `fname` and `surename` into single field
|
||||
|
||||
interface IUser {
|
||||
uname: string;
|
||||
pass: string;
|
||||
room?: number;
|
||||
admin?: number;
|
||||
locked?: boolean;
|
||||
fname?: string;
|
||||
surname?: string;
|
||||
}
|
||||
|
||||
const userSchema = new Schema<IUser>({
|
||||
uname: {type: String, required: true},
|
||||
pass: {type: String, required: true, default: "$2y$10$wxDhf.XiXkmdKrFqYUEa0.F4Bf.pDykZaMmgjvyLyeRP3E/Xy0hbC"},
|
||||
room: Number,
|
||||
admin: Number,
|
||||
locked: {type: Boolean, default: false},
|
||||
fname: String,
|
||||
surname: String
|
||||
})
|
||||
|
||||
export default mongoose.model("logins", userSchema)
|
||||
19
src/schemas/Vote.ts
Normal file
19
src/schemas/Vote.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import mongoose, { Schema } from "mongoose";
|
||||
|
||||
interface IVote {
|
||||
doc: Date;
|
||||
user: mongoose.Types.ObjectId;
|
||||
dom: Date;
|
||||
tom: "ob" | "kol";
|
||||
vote: "-" | "+" | "n";
|
||||
}
|
||||
|
||||
const voteSchema = new Schema<IVote>({
|
||||
doc: {type: Date, required: true},
|
||||
user: {type: mongoose.Schema.Types.ObjectId, required: true},
|
||||
dom: {type: Date, required: true},
|
||||
tom: {type: String, required: true},
|
||||
vote: {type: String, required: true},
|
||||
})
|
||||
|
||||
export default mongoose.model("vote", voteSchema)
|
||||
Reference in New Issue
Block a user