Skip to content

Commit

Permalink
feat: delete AdoptionChat when an animal is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAlbDR committed Apr 15, 2024
1 parent 06e3369 commit 28e7987
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/presentation/animals/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ export class AnimalService {
animal.type
);

// Delete animal AdoptionChats
await prisma.adoptionChat.deleteMany({
where: {
animal: {
some: {
id: animal.id,
},
},
},
});

await prisma.animal.delete({ where: { id: animal.id } });

const imagesToDelete = animal.images.map((image) => image) || [];
Expand Down

0 comments on commit 28e7987

Please sign in to comment.