SoftDelete
Exclusão de segurança, recebe como parâmetro o tipo da entidade para invalidá-la ou um tipo { chave: valor } e invalida todos os dados relacionados (não os exclui).
const example = await this.examplesRepository.findBy(
{ where: { id: 123 } },
trx,
);
if (!example) {
throw new AppError("NOT_FOUND", "Example not found");
};
await this.examplesRepository.softDelete({ id: example.id }, trx);
// exemplo de invalidação
await this.examplesRepository.softDelete({ name: "example" }, trx);
// invalida todos onde name = example
Was this helpful?