From c2715b5ca10112b21b5300e69a003762b6a78e67 Mon Sep 17 00:00:00 2001 From: juandans01 Date: Mon, 16 Jan 2023 12:27:58 -0300 Subject: [PATCH] add explanations orderg --- .../1673279347037-add_index_to_explanations.ts | 18 ++++++++++++++++++ .../controllers/list.question.controller.ts | 4 ---- .../question/domain/explanation.entity.ts | 3 +++ .../question/dto/create.question.dto.ts | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/migrations/1673279347037-add_index_to_explanations.ts diff --git a/src/migrations/1673279347037-add_index_to_explanations.ts b/src/migrations/1673279347037-add_index_to_explanations.ts new file mode 100644 index 0000000..5b9efba --- /dev/null +++ b/src/migrations/1673279347037-add_index_to_explanations.ts @@ -0,0 +1,18 @@ +import {MigrationInterface, QueryRunner, TableColumn} from "typeorm"; + +export class addIndexToExplanations1673279347037 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn( + "explanations", + new TableColumn({ + name: "explanation_index", + type: "varchar", + }), + ) + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/src/modules/question/controllers/list.question.controller.ts b/src/modules/question/controllers/list.question.controller.ts index d8b9276..012d886 100644 --- a/src/modules/question/controllers/list.question.controller.ts +++ b/src/modules/question/controllers/list.question.controller.ts @@ -24,10 +24,6 @@ export class ListQuestionController { .leftJoinAndSelect('question.explanations', 'explanations') .take(10); - console.log( - '🚀 ~ file: list.question.controller.ts:23 ~ ListQuestionController ~ handler ~ apps', - apps, - ); if (apps.length > 0) { query.where('apps.id IN(:...ids)', { ids: apps }); } diff --git a/src/modules/question/domain/explanation.entity.ts b/src/modules/question/domain/explanation.entity.ts index a9a9d6a..ed11474 100644 --- a/src/modules/question/domain/explanation.entity.ts +++ b/src/modules/question/domain/explanation.entity.ts @@ -15,6 +15,9 @@ export class Explanation { @PrimaryGeneratedColumn() id: number; + @Column({ name: 'explanation_index', length: 150 }) + index: string; + @Column({ name: 'explanation_position', length: 150 }) position: string; diff --git a/src/modules/question/dto/create.question.dto.ts b/src/modules/question/dto/create.question.dto.ts index bec2c2a..e9e72ab 100644 --- a/src/modules/question/dto/create.question.dto.ts +++ b/src/modules/question/dto/create.question.dto.ts @@ -8,6 +8,7 @@ export class CreateQuestionDto { } explanations?: { position: string; + index: string; text: string; }[] } \ No newline at end of file