Cambios en las relaciones de evento, participante_evento y participante.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { CuestionarioRespondido } from "src/cuestionario_respondido/entities/cuestionario_respondido.entity";
|
||||
import { Evento } from "src/evento/evento.entity";
|
||||
import { ParticipanteEvento } from "src/participante_evento/participante_evento.entity";
|
||||
import { TipoUser } from "src/tipo_user/tipo_user.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { Column, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity()
|
||||
export class Participante {
|
||||
@@ -16,19 +18,32 @@ export class Participante {
|
||||
//Relacion con tipo usuario
|
||||
@ManyToOne(() => TipoUser, tipoUser => tipoUser.participante)
|
||||
@JoinColumn({ name: 'participante_id' }) //nombre de la relacion
|
||||
tipo_user: TipoUser[]
|
||||
tipo_user: TipoUser
|
||||
|
||||
/*
|
||||
@ManyToOne(() => Administrador, (admin) => admin.eventos)
|
||||
@JoinColumn({ name: "id_administrador" })
|
||||
administrador: Administrador;
|
||||
|
||||
@OneToMany(() => ParticipanteEvento, (pe) => pe.evento)
|
||||
participantes: ParticipanteEvento[];
|
||||
@ManyToMany(() => Evento, evento => evento.participantes)
|
||||
@JoinTable({
|
||||
name: "participante_evento",
|
||||
joinColumn: { name: "id_participante", referencedColumnName: "id_participante" },
|
||||
inverseJoinColumn: { name: "id_evento", referencedColumnName: "id_evento" }
|
||||
})
|
||||
eventos: Evento[];
|
||||
|
||||
@OneToMany(() => Asistencia, (asistencia) => asistencia.evento)
|
||||
asistencias: Asistencia[];
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@OneToMany(() => CuestionarioRespondido, cuestionario => cuestionario.id_participante)
|
||||
cuestionariosRespondidos: CuestionarioRespondido[];
|
||||
|
||||
@OneToMany(() => ParticipanteEvento, participanteEvento => participanteEvento.participante)
|
||||
participanteEventos: ParticipanteEvento[];
|
||||
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Participante } from './participante.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CreateParticipanteDto } from './dto/create-participante.dto';
|
||||
import { UpdateAdminDto } from 'src/admin/dto/update.admin.dto';
|
||||
//import { UpdateAdminDto } from 'src/admin/dto/update.admin.dto';
|
||||
import { UpdateParticipanteDto } from './dto/update.participante.dto';
|
||||
|
||||
@Injectable()
|
||||
@@ -28,7 +28,7 @@ export class ParticipanteService {
|
||||
|
||||
getParticipantes() {
|
||||
return this.participanteRepository.find({
|
||||
relations: ['tipo_user']
|
||||
relations: ['tipo_user', 'participanteEventos']
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class ParticipanteService {
|
||||
where: {
|
||||
id_participante
|
||||
},
|
||||
relations: ['tipo_user']
|
||||
relations: ['tipo_user', 'participanteEventos']
|
||||
})
|
||||
|
||||
if (!participanteFound)
|
||||
|
||||
Reference in New Issue
Block a user