Skip to main content
TypeOrm supports soft deletes. This feature does not delete records but instead updates the column decorated with @DeleteDateColumn. Before continuing it is recommended that you read the following.

Setting up your entity.

Before enabling soft deletes you must add the DeleteDateColumn to your entity.
todo-item.entity.ts
The important column is the deletedAt column in the above example. Without this column soft deletes will not work. If you add this column all reads from the typeorm repository will add a where clause checking that the column IS NULL.

Soft Delete Service

Once you have added the column to your entity you need to declare your service setting the useSoftDelete flag.
todo-item.service.ts
Notice that when calling super the useSoftDelete option is set to true. This will ensure that all deletes use the softRemove when deleting one or softDelete when deleting many.

Adding restore mutations.

nestjs-query does not automatically expose restore mutations. In this example we add the restore mutations.
todo-item.resolver.ts

Complete Example

To see a complete example see here.