Delete

Classic delete, receives as parameter the type of the entity to delete it or a { key: value } to delete all related data.

const example = await this.examplesRepository.findBy(
  { where: { id: 123 } },
  trx,
);

if (!example) {
  throw new AppError("NOT_FOUND", "Example not found");
};

await this.examplesRepository.delete({ id: example.id }, trx);

// delete example
await this.examplesRepository.delete({ name: "example" }, trx);

// delete all where name = example