refactor(backend): Functions
This commit is contained in:
parent
5ec62554e3
commit
65c1a5e6b6
57 changed files with 172 additions and 117 deletions
|
@ -4,7 +4,7 @@ import { Question } from '../../entities/questions/question.entity.js';
|
|||
import { Teacher } from '../../entities/users/teacher.entity.js';
|
||||
|
||||
export class AnswerRepository extends DwengoEntityRepository<Answer> {
|
||||
public createAnswer(answer: { toQuestion: Question; author: Teacher; content: string }): Promise<Answer> {
|
||||
public async createAnswer(answer: { toQuestion: Question; author: Teacher; content: string }): Promise<Answer> {
|
||||
const answerEntity = this.create({
|
||||
toQuestion: answer.toQuestion,
|
||||
author: answer.author,
|
||||
|
@ -13,13 +13,13 @@ export class AnswerRepository extends DwengoEntityRepository<Answer> {
|
|||
});
|
||||
return this.insert(answerEntity);
|
||||
}
|
||||
public findAllAnswersToQuestion(question: Question): Promise<Answer[]> {
|
||||
public async findAllAnswersToQuestion(question: Question): Promise<Answer[]> {
|
||||
return this.findAll({
|
||||
where: { toQuestion: question },
|
||||
orderBy: { sequenceNumber: 'ASC' },
|
||||
});
|
||||
}
|
||||
public removeAnswerByQuestionAndSequenceNumber(question: Question, sequenceNumber: number): Promise<void> {
|
||||
public async removeAnswerByQuestionAndSequenceNumber(question: Question, sequenceNumber: number): Promise<void> {
|
||||
return this.deleteWhere({
|
||||
toQuestion: question,
|
||||
sequenceNumber: sequenceNumber,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue