xorm
xorm copied to clipboard
It is recommended to set a soft deleted tag.
It is recommended to set a soft deleted tag. You can set a field to identify the field for soft deletion, and specify a value to indicate that the record is in a soft delete state when the field is at that value. The original soft delete tag function is too primitive
There is already a deleted
tag.
Deleting a tag can only identify the type time.Time field and can only update it to the current time. If I can identify a string or number and specify the value of the field when I delete it, I think the scalability will be better.
eg:
type Demo struct {
Id uint64 `json:"id,string" xorm:"not null pk BIGINT(20) 'id'"`
Name uint64 `json:"name" xorm:"not null comment('name') VARCHAR 'name'"`
Age uint64 `json:"age" xorm:"comment('age') INT 'age'"`
//This is the field that identifies the deletion. A value of 1 indicates that the record is in a soft delete state.
IsDelete int `json:"isDelete" xorm:"not null INT deleted 1 is_delete"`
}
I think deleted
should support int64
. if the int64
> 0 then it's deleted and with timestamp otherwise it's not deleted.
I want it to be deleted when it is not set to a timestamp, but to a value I specify