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