feat: add join columns
This commit is contained in:
@@ -41,22 +41,9 @@ export class QuestionsCommandProvider {
|
||||
public async createOne(createQuestionDto: CreateQuestionDTO) {
|
||||
const test = await this.testsService.adminGetOne(createQuestionDto.test);
|
||||
|
||||
let maxOrder: { max: string } | undefined;
|
||||
|
||||
try {
|
||||
maxOrder = await this.questionsRepository
|
||||
.createQueryBuilder('q')
|
||||
.select('MAX(q.order)', 'max')
|
||||
.where('q.testId = :testId', { testId: test.id })
|
||||
.getRawOne();
|
||||
} catch (err) {
|
||||
throw new AppTimeoutException(err);
|
||||
}
|
||||
|
||||
const newQuestion = this.questionsRepository.create({
|
||||
...createQuestionDto,
|
||||
test,
|
||||
order: (Number(maxOrder?.max) || 0) + 1,
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user