Loading backend/src/database-seeder/database-seeder.module.ts +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ import { PointOfInterest } from 'src/pointOfInterest/entities/PointOfInterest.en import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfInterestTraduction.entity'; import { CategoryService } from 'src/category/category.service'; import { Category } from 'src/category/entities/category.entity'; @Module({ providers: [ Loading @@ -31,6 +33,7 @@ import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfI TownService, PointOfInterestService, PlaceService, CategoryService, ], imports: [ TypeOrmModule.forFeature([ Loading @@ -44,6 +47,7 @@ import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfI AvailableDate, PlaceTraduction, PointOfInterestTraduction, Category, ]), ], }) Loading backend/src/database-seeder/database-seeder.service.ts +29 −4 Original line number Diff line number Diff line Loading @@ -10,8 +10,8 @@ import { UserStatus } from 'src/shared/enum/user-status.enum'; import { AuthAdminService } from 'src/auth/admin/authAdmin.service'; import { TownService } from 'src/town/town.service'; import { CreateTownDto } from 'src/town/dto/create-town.dto'; import { PointOfInterestService } from 'src/pointOfInterest/PointOfInterest.service'; import { PlaceService } from 'src/place/place.service'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; import { Category } from 'src/category/entities/category.entity'; @Injectable() export class DatabaseSeederService implements OnModuleInit { Loading @@ -20,8 +20,7 @@ export class DatabaseSeederService implements OnModuleInit { private readonly stateService: StateService, private readonly authAdminService: AuthAdminService, private readonly townService: TownService, private readonly activityService: PointOfInterestService, private readonly placeService: PlaceService, @InjectRepository(Category) private categoryRepo: Repository<Category>, ) {} async insertStates() { Loading Loading @@ -93,9 +92,35 @@ export class DatabaseSeederService implements OnModuleInit { await this.townService.create(town); } async insertCategories() { const categoriesES = [ { idCategory: 1, language: LANGUAGES.ES, name: 'Arquitectura' }, { idCategory: 2, language: LANGUAGES.ES, name: 'Comida' }, ]; const categoriesEN = [ { idCategory: 1, language: LANGUAGES.EN, name: 'Architecture' }, { idCategory: 2, language: LANGUAGES.EN, name: 'Food' }, ]; for (let i = 0; i < categoriesES.length; i++) { await this.categoryRepo.upsert( [{ idCategory: categoriesES[i].idCategory, language: LANGUAGES.ES, name: categoriesES[i].name }], { conflictPaths: ['idCategory', 'language'], }, ); await this.categoryRepo.upsert( [{ idCategory: categoriesES[i].idCategory, language: LANGUAGES.EN, name: categoriesEN[i].name }], { conflictPaths: ['idCategory', 'language'], }, ); } } async onModuleInit() { await this.insertStates(); await this.insertSuperAdmin(); await this.insertTowns(); await this.insertCategories(); } } Loading
backend/src/database-seeder/database-seeder.module.ts +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ import { PointOfInterest } from 'src/pointOfInterest/entities/PointOfInterest.en import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfInterestTraduction.entity'; import { CategoryService } from 'src/category/category.service'; import { Category } from 'src/category/entities/category.entity'; @Module({ providers: [ Loading @@ -31,6 +33,7 @@ import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfI TownService, PointOfInterestService, PlaceService, CategoryService, ], imports: [ TypeOrmModule.forFeature([ Loading @@ -44,6 +47,7 @@ import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfI AvailableDate, PlaceTraduction, PointOfInterestTraduction, Category, ]), ], }) Loading
backend/src/database-seeder/database-seeder.service.ts +29 −4 Original line number Diff line number Diff line Loading @@ -10,8 +10,8 @@ import { UserStatus } from 'src/shared/enum/user-status.enum'; import { AuthAdminService } from 'src/auth/admin/authAdmin.service'; import { TownService } from 'src/town/town.service'; import { CreateTownDto } from 'src/town/dto/create-town.dto'; import { PointOfInterestService } from 'src/pointOfInterest/PointOfInterest.service'; import { PlaceService } from 'src/place/place.service'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; import { Category } from 'src/category/entities/category.entity'; @Injectable() export class DatabaseSeederService implements OnModuleInit { Loading @@ -20,8 +20,7 @@ export class DatabaseSeederService implements OnModuleInit { private readonly stateService: StateService, private readonly authAdminService: AuthAdminService, private readonly townService: TownService, private readonly activityService: PointOfInterestService, private readonly placeService: PlaceService, @InjectRepository(Category) private categoryRepo: Repository<Category>, ) {} async insertStates() { Loading Loading @@ -93,9 +92,35 @@ export class DatabaseSeederService implements OnModuleInit { await this.townService.create(town); } async insertCategories() { const categoriesES = [ { idCategory: 1, language: LANGUAGES.ES, name: 'Arquitectura' }, { idCategory: 2, language: LANGUAGES.ES, name: 'Comida' }, ]; const categoriesEN = [ { idCategory: 1, language: LANGUAGES.EN, name: 'Architecture' }, { idCategory: 2, language: LANGUAGES.EN, name: 'Food' }, ]; for (let i = 0; i < categoriesES.length; i++) { await this.categoryRepo.upsert( [{ idCategory: categoriesES[i].idCategory, language: LANGUAGES.ES, name: categoriesES[i].name }], { conflictPaths: ['idCategory', 'language'], }, ); await this.categoryRepo.upsert( [{ idCategory: categoriesES[i].idCategory, language: LANGUAGES.EN, name: categoriesEN[i].name }], { conflictPaths: ['idCategory', 'language'], }, ); } } async onModuleInit() { await this.insertStates(); await this.insertSuperAdmin(); await this.insertTowns(); await this.insertCategories(); } }