se crearon algunas tablas

This commit is contained in:
2025-03-28 11:26:11 -06:00
parent 767a765f68
commit b95779531b
34 changed files with 579 additions and 6 deletions
+11 -1
View File
@@ -1 +1,11 @@
export class CreateOpcionDto {}
import { IsString, MaxLength } from "class-validator";
export class CreateOpcionDto {
@IsString()
@MaxLength(50)
opcion: string;
}
+15
View File
@@ -0,0 +1,15 @@
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
@Entity()
export class Opcion {
@PrimaryGeneratedColumn()
id_opcion: number;
@Column({ type: String, nullable: false, length: 200, default: '' })
opcion: string;
@OneToMany(() => PreguntaOpcion, (preguntaOpcion) => preguntaOpcion.Opcion)
Preguntas: PreguntaOpcion[];
}
+12 -2
View File
@@ -1,11 +1,21 @@
import { Injectable } from '@nestjs/common';
import { CreateOpcionDto } from './dto/create-opcion.dto';
import { UpdateOpcionDto } from './dto/update-opcion.dto';
import { Opcion } from './entities/opcion.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
@Injectable()
export class OpcionService {
create(createOpcionDto: CreateOpcionDto) {
return 'This action adds a new opcion';
constructor(
@InjectRepository(Opcion)
private repository: Repository<Opcion>,
){}
create():Promise<Opcion> {
return this.repository.save(this.repository.create());
}
findAll() {