add carrera
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { CarreraService } from './carrera.service';
|
||||
|
||||
@Controller('carrera')
|
||||
export class CarreraController {
|
||||
constructor(private readonly carreraService: CarreraService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.carreraService.findAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CarreraService } from './carrera.service';
|
||||
import { CarreraController } from './carrera.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Carrera } from './entities/carrera.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Carrera])],
|
||||
controllers: [CarreraController],
|
||||
providers: [CarreraService],
|
||||
})
|
||||
export class CarreraModule {}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Carrera } from './entities/carrera.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class CarreraService {
|
||||
constructor(
|
||||
@InjectRepository(Carrera)
|
||||
private readonly carreraRepository: Repository<Carrera>,
|
||||
) {}
|
||||
findAll() {
|
||||
return this.carreraRepository.find();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateCarreraDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCarreraDto } from './create-carrera.dto';
|
||||
|
||||
export class UpdateCarreraDto extends PartialType(CreateCarreraDto) {}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Alumno } from 'src/alumno/entities/student.entity';
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'carrera' })
|
||||
export class Carrera {
|
||||
@PrimaryGeneratedColumn({ name: 'id_carrera', type: 'int', unsigned: true })
|
||||
id_carrera: number;
|
||||
|
||||
@Column({
|
||||
name: 'carrera',
|
||||
type: 'varchar',
|
||||
length: 100,
|
||||
nullable: false,
|
||||
})
|
||||
carrera: string;
|
||||
|
||||
@OneToMany(() => Alumno, (student) => student.carrera)
|
||||
estudiantes: Alumno[];
|
||||
}
|
||||
Reference in New Issue
Block a user