Open
Description
- We often require an auto incremented id or
sId
that needs to be displayed on the front-end for user experience purposes and it is good to have this id for all our models. - In a business, we never hard delete anything, no matter how small it is. So, it makes sense that we have a soft delete column
deletedAt
like createdAt and updatedAt, that will be just need to be updated by the current date while deleting and we can restore that row whenever we need by just setting the same column to null.
Although, it will require additional work on developer side to make sure that while querying the data, is mode.deletedAt IS NULL
filter is applied in where filter or not. Some ORMS like typeORM, Sequelize, Prisma provides auto check of deletedAt is null but for the case of drizzleORM, we'll have to manually check for the deletedAt column, but its a simple enough task.