Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Created models #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
26 changes: 26 additions & 0 deletions src/models/courses/credits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Schema, mongo } from "mongoose";

const CreditsSchema = new Schema({
theory: {
type:Number,
required: true,
},
practice:{
type:Number,
required: true,
},
lab:{
type:Number,
required: true,
},
ects:{
type:Number,
required: true,
},
credits:{
type:Number,
required: true,
},
});

export default CreditsSchema;
14 changes: 14 additions & 0 deletions src/models/courses/department.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Schema, mongo } from "mongoose";

const Department = new Schema({
name: {
type: String,
required: true,
},
department: {
type: new mongo.ObjectID(),
required: true,
}
});

export default Department;
33 changes: 33 additions & 0 deletions src/models/courses/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Schema, mongo } from "mongoose";
import CreditsSchema from "./credits";
import Department from "./department";

const CoursesSchema = new Schema({
prefix: String,
language: {
type: String,
default: "en",
enum: ["en", "ru", "kz"],
},
title: {
type: String,
required: true,
},
date: {
type: Date,
required: true
},
code: {
type: String,
required: true,
},
credits: CreditsSchema,
description: {
type: String,
required: true,
},
prerequisites: [new mongo.ObjectID()],
department: Department,
});

export default CoursesSchema;
18 changes: 18 additions & 0 deletions src/models/curriculums/electives.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Schema, mongo } from "mongoose";

const ElectivesSchema = new Schema({
area: {
type:new mongo.ObjectID(),
required: true,
},
nonArea: {
type:new mongo.ObjectID(),
required: true,
},
nonTheoretical: {
type:new mongo.ObjectID(),
required: true,
},
});

export default ElectivesSchema;
36 changes: 36 additions & 0 deletions src/models/curriculums/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Schema, mongo } from "mongoose";
import ElectivesSchema from "./electives";
import SemesterSchema from "./semester";

const CurriculumSchema = new Schema({
title: {
type:String,
required: true,
},
year: {
type:Number,
required: true,
},
cipher: {
type:String,
required: true,
},
level: {
type:String,
required: true,
},
electives: {
type:ElectivesSchema,
required: true,
},
code: {
type:String,
required: true,
},
semester: {
type:SemesterSchema,
required: true,
}
});

export default CurriculumSchema;
19 changes: 19 additions & 0 deletions src/models/curriculums/semester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Schema, mongo } from "mongoose";
import ElectivesSchema from "./electives";

const SemesterSchema = new Schema({
index: {
type:Number,
required: true,
},
courses: {
type:new mongo.ObjectID(),
required: true,
},
group: {
type: [ElectivesSchema],
required: true,
},
});

export default SemesterSchema;
10 changes: 10 additions & 0 deletions src/models/departments/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Schema } from "mongoose";

const ManagerSchema = new Schema({
fullName: {
type:String,
required: true,
},
});

export default ManagerSchema;
18 changes: 18 additions & 0 deletions src/models/departments/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Schema, mongo } from "mongoose";
import ManagerSchema from "./manager";
import TitleSchema from "./title";

const DepartmentSchema = new Schema({
title: {
type:TitleSchema,
required: true,
},
prefixes: [String],
managers: [ManagerSchema],
curriculums: {
type:new mongo.ObjectID(),
required: true,
},
});

export default DepartmentSchema;
10 changes: 10 additions & 0 deletions src/models/departments/title.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Schema, mongo } from "mongoose";

const TitleSchema = new Schema({
title: {
type:String,
required: true,
},
});

export default TitleSchema;
8 changes: 8 additions & 0 deletions src/models/userAdditionals/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import IUserAdditional from "./interface";
import AdditionalsSchema from "./schema";
import { IModel, ModelNames } from "@/@types";
import { createModels } from "@/utils";

const models: IModel<IUserAdditional> = createModels(ModelNames.USERS, AdditionalsSchema);

export default models;
Empty file.
33 changes: 33 additions & 0 deletions src/models/userAdditionals/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Schema, mongo } from "mongoose";

const MainInfo = new Schema({
status: {
type: String,
required: true,
default: "Studying",
},
});

const ContactInfo = new Schema({
phone: {
type: String,
required: true,
unique: true,
},
email: {
type: String,
required: true,
unique: true,
},
});

const AdditionalsSchema = new Schema({
user: {
type:new mongo.ObjectID(),
required: true,
},
main: MainInfo,
contacts: ContactInfo
});

export default AdditionalsSchema;