Skip to content

Commit

Permalink
feat: student schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shikharvashistha authored May 31, 2022
1 parent e3eda2d commit 10db08c
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 3 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@
"jwt-decode": "^3.1.2",
"moment": "^2.29.3",
"multer": "^1.4.4",
"mysql2": "^2.3.3",
"object-resolve-path": "^1.1.1",
"pg": "^8.7.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"swagger-ui-express": "^4.3.0",
"templates.js": "^0.3.11"
"templates.js": "^0.3.11",
"typeorm": "^0.3.6"
},
"devDependencies": {
"@nestjs/cli": "^8.0.0",
Expand Down
6 changes: 4 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CacheModule, Module } from "@nestjs/common";
import { Module } from "@nestjs/common";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { StudentModule } from "./student/student.module";
Expand All @@ -9,10 +9,12 @@ import { GroupModule } from "./group/group.module";
import { HolidayModule } from "./holiday/holiday.module";
import { ConfigurationModule } from "./configs/configuration.module";
import { ConfigModule } from "@nestjs/config";
import { DatabaseProviders } from "./database.provider";
import { GroupMembershipModule } from "./groupMembership/groupMembership.module";
import { NotificationModule } from "./notification/notification.module";
import { TemplateModule } from "./template/template.module";
import { MulterModule } from "@nestjs/platform-express/multer";

@Module({
imports: [
ConfigModule.forRoot(),
Expand All @@ -31,6 +33,6 @@ import { MulterModule } from "@nestjs/platform-express/multer";
NotificationModule,
],
controllers: [AppController],
providers: [AppService],
providers: [AppService, ...DatabaseProviders],
})
export class AppModule {}
20 changes: 20 additions & 0 deletions src/database.provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { DataSource } from "typeorm";

export const DatabaseProviders = [
{
provide: "DATA_SOURCE",
useFactory: async () => {
const dataSource = new DataSource({
type: "postgres",
host: "localhost",
port: 5432,
database: "postgres",
password: "postgres",
username: "postgres",
entities: [__dirname + "./entities/**/*.ts"],
synchronize: true,
});
return dataSource.initialize();
},
},
];
70 changes: 70 additions & 0 deletions src/entities/student.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class Student {
@PrimaryGeneratedColumn()
studentId: string;

@Column({ type: "string" })
aadhaar: string;

@Column({ type: "string" })
refStudentId: string;

@Column({ type: "character varying" })
firstName: string;

@Column({ type: "character varying" })
lastName: string;

@Column({ type: "integer" })
contactNumber: number;

@Column({ type: "string" })
email: string;

@Column({ type: "character varying", length: 1 })
gender: string;

@Column({ type: "character varying", length: 1 })
socialCategory: string;

@Column({ type: "character varying", length: 1 })
iscwsn: string;

@Column({ type: "character varying", length: 1 })
religion: string;

@Column({ type: "character varying", length: 1 })
singleGirl: string;

@Column({ type: "real" })
weight: number;

@Column({ type: "real" })
height: number;

@Column({ type: "character varying", length: 1 })
bloodGroup: string;

@Column({ type: "date" })
birthDate: Date;

@Column({ type: "character varying", length: 1 })
homeless: string;

@Column({ type: "character varying", length: 1 })
bpl: string;

@Column({ type: "character varying", length: 1 })
migrant: string;

@Column({ type: "string" })
schoolId: string;

@Column({ type: "string" })
classId: string;

@Column({ type: "character varying", length: 1 })
status: string;
}
24 changes: 24 additions & 0 deletions src/interface/student.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface StudentInterface extends Document {
readonly studentId: string;
readonly aadhaar: string;
readonly refStudentId: string;
readonly firstName: string;
readonly lastName: string;
readonly contactNumber: number;
readonly email: string;
readonly gender: string;
readonly socialCategory: string;
readonly iscwsn: string;
readonly religion: string;
readonly singleGirl: string;
readonly weight: number;
readonly height: number;
readonly bloodGroup: string;
readonly birthDate: Date;
readonly homeless: string;
readonly bpl: string;
readonly migrant: string;
readonly schoolId: string;
readonly classId: string;
readonly status: string;
}

0 comments on commit 10db08c

Please sign in to comment.