21 lines
531 B
TypeScript
21 lines
531 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
|
|
import { Repository } from 'typeorm';
|
|
|
|
import { Question } from './entities/question.entity';
|
|
import { Poll } from './entities/poll.entity';
|
|
|
|
@Injectable()
|
|
export class QuestionsService {
|
|
constructor(
|
|
@InjectRepository(Question)
|
|
private questionRepository: Repository<Question>,
|
|
) {}
|
|
|
|
get(poll: Poll, questionId: number) {
|
|
const question = poll.questions.find((q) => q.id == questionId);
|
|
return question;
|
|
}
|
|
}
|