Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To retrieve soft-deleted entities in TypeORM PostgreSQl, you can use the find method with an additional withDeleted method. Here is an example:

const deletedEntities = await repository.find({ withDeleted: true });

This will fetch all the entities, including the ones that were soft-deleted. You can also filter the retrieved entities further by using the where option.

const deletedEntities = await repository.find({
    withDeleted: true,
    where: { deletedAt: Not(null) } 
});

This will retrieve all the entities that have a deletedAt field with a value, indicating that they have been soft-deleted.