go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
37.02k stars 3.94k forks source link

Can soft delete specify a delId field that is set to the value of id instead of creation time to avoid deletion conflicts? #7186

Open thislyc opened 2 months ago

thislyc commented 2 months ago

Describe the feature

The feature request is to enhance the soft delete functionality by allowing the specification of a delId field. This field would be set to the value of the id field (or another unique identifier) instead of using the creation time when marking a record as deleted. This approach aims to provide a unique and consistent reference for each deleted record, reducing the risk of conflicts or ambiguities that may arise when relying on timestamps.

Motivation

The motivation behind this feature is to address potential conflicts and ambiguities in systems that utilize soft deletes. By using the id field, which is inherently unique, as the value for the delId field, we can ensure that each deletion operation is traceable and distinct. This can be particularly beneficial in systems with high concurrency or those that require precise audit trails. Additionally, using the id field helps in maintaining referential integrity and simplifying queries that involve deleted records.

Related Issues

https://github.com/go-gorm/gorm/issues/4047

thislyc commented 2 months ago

@jinzhu I can provide a pr, which github repository should it be in?