add fk to entity
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
import { Question } from './question.entity';
|
import { Question } from './question.entity';
|
||||||
import { User } from './user.entity';
|
import { User } from './user.entity';
|
||||||
import { QuestionOption } from './questionOptions';
|
import { QuestionOption } from './questionOptions';
|
||||||
|
import { Choice } from './choice.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Unique(['questionOption', 'user'])
|
@Unique(['questionOption', 'user'])
|
||||||
@@ -15,6 +16,14 @@ export class Answer {
|
|||||||
@PrimaryGeneratedColumn({})
|
@PrimaryGeneratedColumn({})
|
||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => Question, (question: Question) => question.answers)
|
||||||
|
@JoinColumn([{ name: 'questionId', referencedColumnName: 'id' }])
|
||||||
|
question: Question;
|
||||||
|
|
||||||
|
@ManyToOne(() => Choice)
|
||||||
|
@JoinColumn([{ name: 'choiceId', referencedColumnName: 'id' }])
|
||||||
|
choice: Choice;
|
||||||
|
|
||||||
@ManyToOne(() => QuestionOption)
|
@ManyToOne(() => QuestionOption)
|
||||||
@JoinColumn([
|
@JoinColumn([
|
||||||
{ name: 'questionId', referencedColumnName: 'question' },
|
{ name: 'questionId', referencedColumnName: 'question' },
|
||||||
@@ -22,10 +31,6 @@ export class Answer {
|
|||||||
])
|
])
|
||||||
questionOption: QuestionOption;
|
questionOption: QuestionOption;
|
||||||
|
|
||||||
@ManyToOne(() => Question, (question: Question) => question.answers)
|
|
||||||
@JoinColumn([{ name: 'questionId', referencedColumnName: 'id' }])
|
|
||||||
question: Question;
|
|
||||||
|
|
||||||
@ManyToOne(() => User)
|
@ManyToOne(() => User)
|
||||||
user: User;
|
user: User;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user