Describe the feature
The GORM docs (https://gorm.io/docs/models.html) describe conventions for using UNIX time stamps at seconds, millis, and nano granularity for CreatedAt and UpdatedAt fields but not for DeletedAt.
I'd like to explore what is needed to add support for something akin to
type User struct {
DeletedAt int64 `gorm:"autoDeleteTime"`
DeletedAt int64 `gorm:"autoDeleteTime:milis"`
DeletedAt int64 `gorm:"autoDeleteTime:nanos"`
}
Or if it is desirable to reshape the gorm.DeletedAt type alias:
type User struct {
DeletedAt gorm.DeletedAt `gorm:"autoDeleteTime"`
DeletedAt gorm.DeletedAt `gorm:"autoDeleteTime:milis"`
DeletedAt gorm.DeletedAt `gorm:"autoDeleteTime:nanos"`
}
where that type alias embeds a UNIX-style timestamp field as an int64 in addition to or as a replacement for sql.NullTime.
Motivation
A lot of the databases we and others have in production standardize around UNIX timestamp values. This is the case for the CreatedAt and UpdatedAt fields. For consistency, gorm should also support this for DeletedAt timestamp.
Related Issues
n/a
Comment From: jinzhu
We are not going to support the autoDeleteTime tag, but you can try with this plugin https://github.com/go-gorm/soft_delete
It should resolve your problem.