반응형
테이블 nestj 자동 생성에 대한 TypeORM 요청
테이블이 2개 있습니다.teams그리고.usersType ORM에 의해 자동 생성되는2개의 중앙 테이블이 있습니다.
MySQLWorkbench의 표는 다음과 같습니다.

여기 엔티티에 대한 단편들이 있습니다.
users.displaces
import { Teams } from './teams.entity';
import { Feedbacklog } from './feedbacklog.entity';
import { Entity, PrimaryGeneratedColumn, Column, OneToMany, ManyToMany, ManyToOne } from 'typeorm';
@Entity({
name: 'users',
})
export class Users {
@PrimaryGeneratedColumn({
name: 'userID',
})
userID: number;
@Column('varchar', {
nullable: false,
length: 100,
name: 'email',
})
email: string;
@Column('varchar', {
nullable: false,
length: 200,
name: 'password',
})
password: string;
@Column('varchar', {
nullable: false,
length: 20,
unique: true,
name: 'username',
})
username: string;
@Column('varchar', {
nullable: false,
length: 35,
name: 'firstName',
})
firstName: string;
@Column('varchar', {
nullable: true,
length: 35,
name: 'lastName',
})
lastName: string | null;
@Column('int', {
nullable: false,
default: 0,
name: 'receivedFeedbacks',
})
receivedFeedbacks: number;
@Column('int', {
nullable: false,
default: 0,
name: 'givenFeedbacks',
})
givenFeedbacks: number;
@Column('varchar', {
nullable: false,
length: 20,
default: 'User',
name: 'role',
})
role: string;
@ManyToMany(type => Teams, team => team.user)
team: Teams[];
@OneToMany(type => Feedbacklog, feedbacklog => feedbacklog.receiver, { eager: true })
received: Feedbacklog[];
@OneToMany(type => Feedbacklog, feedbacklog => feedbacklog.sender, { eager: true })
sent: Feedbacklog[];
}
teams.displays(팀).
import { Entity, PrimaryGeneratedColumn, Column, OneToMany, ManyToMany, JoinTable } from 'typeorm';
import { Users } from './users.entity';
@Entity({
name: 'teams'
,
})
export class Teams {
@PrimaryGeneratedColumn({
name: 'teamID',
})
teamID: number;
@Column('varchar', {
nullable: false,
length: 40,
name: 'projectName',
})
projectName: string;
@Column('date', {
nullable: false,
name: 'startDate',
})
startDate: string;
@Column('date', {
nullable: false,
name: 'endDate',
})
endDate: string;
@Column('int', {
nullable: false,
name: 'teamMembers',
})
teamMembers: number;
@ManyToMany(type => Users, {
eager: true,
})
@JoinTable()
user: Users[];
@ManyToMany(type => Users)
@JoinTable()
teamLead: Users[];
}
NestJs를 사용하고 있으며 데이터베이스는 MariaDB입니다.
저 가운데 테이블은 어떻게 접근할 수 있나요?
언급URL : https://stackoverflow.com/questions/53947971/typeorm-request-to-auto-generated-table-nestjs
반응형
'source' 카테고리의 다른 글
| Selenium WebDriver에서 JavaScript를 사용하여 XPath로 요소를 가져오는 방법이 있습니까? (0) | 2022.10.30 |
|---|---|
| 이행 시 부동이지만 이중화되지 않는 필드를 작성하는 방법 (0) | 2022.10.30 |
| PHP 7의 <=>('Spaceship' 연산자)란 무엇입니까? (0) | 2022.10.30 |
| 어레이를 통해 구현된 스택을 사용한 패러테제스 매칭.balanced()를 사용하여 스택이 비어 있는지 체크하기 위해 모든 '(')'에 대해 '(')를 누르고 '(')를 팝핑했습니다. (0) | 2022.10.30 |
| MySQL에서 SELECT DISTINT와 GROUP BY 중 어느 쪽이 빠릅니까? (0) | 2022.10.30 |