Obteniendo campos realcionados
en el servcio twits hay que incorporar en find() y findOne()
relación
async getTwits(): Promise<Twits[]> {
//ahora retornará el await
// find hará un select all de sql, es decir traiem todo
return await this.twitsRepository.find({ relations: ['user'] });
}
async getTwit(id: number): Promise<Twits> {
const twit: Twits = await this.twitsRepository.findOne({
where: { id },
relations: ['user'],
});
if (!twit) {
throw new NotFoundException('Resource Not Found');
}
return twit;
}
0 comentarios:
Publicar un comentario