xorm icon indicating copy to clipboard operation
xorm copied to clipboard

It is recommended to set a soft deleted tag.

Open XHang opened this issue 5 years ago • 5 comments

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

XHang avatar May 27 '19 13:05 XHang

There is already a deleted tag.

lunny avatar May 28 '19 02:05 lunny

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.

XHang avatar May 30 '19 11:05 XHang

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"`
}

XHang avatar May 30 '19 11:05 XHang

I think deleted should support int64. if the int64 > 0 then it's deleted and with timestamp otherwise it's not deleted.

lunny avatar Jun 01 '19 13:06 lunny

I want it to be deleted when it is not set to a timestamp, but to a value I specify

XHang avatar Jun 01 '19 13:06 XHang