feat: answer routes en put question

This commit is contained in:
Gabriellvl 2025-04-06 23:37:54 +02:00
parent 6a1adb0ee3
commit e8e2466b76
12 changed files with 288 additions and 62 deletions

View file

@ -19,10 +19,20 @@ export class AnswerRepository extends DwengoEntityRepository<Answer> {
orderBy: { sequenceNumber: 'ASC' },
});
}
public async findAnswer(question: Question, sequenceNumber: number) {
return this.findOne({
toQuestion: question, sequenceNumber
});
}
public async removeAnswerByQuestionAndSequenceNumber(question: Question, sequenceNumber: number): Promise<void> {
return this.deleteWhere({
toQuestion: question,
sequenceNumber: sequenceNumber,
});
}
public async updateContent(answer: Answer, newContent: string){
answer.content = newContent;
await this.save(answer);
return answer;
}
}

View file

@ -70,4 +70,10 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
sequenceNumber
});
}
public async updateContent(question: Question, newContent: string): Promise<Question> {
question.content = newContent;
await this.save(question);
return question;
}
}