se crearon algunas tablas
This commit is contained in:
@@ -1 +1,11 @@
|
||||
export class CreateOpcionDto {}
|
||||
import { IsString, MaxLength } from "class-validator";
|
||||
|
||||
export class CreateOpcionDto {
|
||||
|
||||
|
||||
@IsString()
|
||||
@MaxLength(50)
|
||||
opcion: string;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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[];
|
||||
|
||||
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user