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

add : TypeORM ERD매핑 #3

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
},
"dependencies": {
"axios": "^0.24.0",
"serverless-http": "^2.7.0"
"mysql2": "^2.3.3-rc.0",
"serverless-http": "^2.7.0",
"typeorm": "0.2.39"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/aws-lambda": "^8.10.84",
"serverless": "^2.64.1",
"serverless-dotenv-plugin": "^3.10.0",
Expand Down
1 change: 1 addition & 0 deletions src/handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

47 changes: 47 additions & 0 deletions src/model/Algorithem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {Entity,PrimaryGeneratedColumn, Column, CreateDateColumn, OneToMany, ManyToOne} from 'typeorm';
import { Emojie } from './emojie'

@Entity()
export class Algorithem {
@PrimaryGeneratedColumn()
post_id: number;

@Column()
post_number: number;

@Column()
title: string;

@Column({length: 1000})
content: string;

@Column()
tag: string;

@CreateDateColumn()
postDate: Date;

@OneToMany(type => Emojie, emojie => emojie.algorithem)
emojies: Emojie[];

@ManyToOne(type => AlgorithemStatus, status => status.algorithems)
algorithem_status: AlgorithemStatus
}

@Entity()
export class AlgorithemStatus {
@PrimaryGeneratedColumn()
status: string;

@OneToMany(type => Algorithem, algorithem => algorithem.algorithem_status)
algorithems: Algorithem[];
}

@Entity()
export class Question {
@PrimaryGeneratedColumn()
id: number;

@Column()
gsm_question: string;
}
36 changes: 36 additions & 0 deletions src/model/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, CreateDateColumn } from 'typeorm';
import { Emojie } from './emojie';

@Entity()
export class User {
@PrimaryGeneratedColumn("uuid")
sub_id: string;

@Column()
email: string;

@Column()
nickname: string;

@Column({type: 'boolean'})
isStudent: boolean;

@CreateDateColumn()
sign_up_time: Date;

@Column()
accessToken: string;

@Column()
refreshed_at: string;

@Column()
expired_at: string;

@Column({type : 'boolean'})
isAdmin: boolean;

@OneToMany(type => Emojie, emojie => emojie.user)
emojies: Emojie[];
}

15 changes: 15 additions & 0 deletions src/model/emojie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Entity, PrimaryGeneratedColumn, Column, ManyToOne} from 'typeorm';
import { User } from './User'
import { Algorithem } from './Algorithem'

@Entity()
export class Emojie {
@PrimaryGeneratedColumn()
emojie_status: string;

@ManyToOne(type => User, user => user.emojies)
user: User;

@ManyToOne(type => Algorithem, algorithem => algorithem.emojies)
algorithem: Algorithem;
}
17 changes: 17 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs", // 모듈을 위한 코드 생성 설정(none, commonjs, amd, system)
"target": "es2020", // 사용할 ECMAScript 버전 설정
"outDir": "dist", // 결과 구조 보내는 디렉터리

"noImplicitAny": true, // any 타입으로 구현된 표현식 혹은 정의 에러처리
"strictPropertyInitialization": false, // 클래스 값 초기화에 엄격한 확인 여부
"moduleResolution": "node", // 모듈 해석 방법
"sourceMap": true, // .map 파일 생성 여부
"experimentalDecorators": true, // ES7의 데코레이터에 대한실험적 지원 여부
"emitDecoratorMetadata": true, // 데코레이터를 위한 타입 메타데이터를 내보내는 것에 대한 실험적 지원 여부
"typeRoots": ["./node_modules/@types"]
},
"include": ["./src/**/*", "./handler.ts"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "node_modules"]
}
Loading