Deleted

Deleted will not really remove one record from table but only tag as deleted via current time. This feature ask you use xorm:"deleted", The field type could be time.Time, type MyTime time.Time or int, int64. For example,

type User struct {
    Id int64
    Name string
    DeletedAt time.Time `xorm:"deleted"`
}

When Delete() will be called, tag deleted will automatically be filled as current time and this record will not be deleted in fact. For example:

var user User
engine.ID(1).Get(&user)
// SELECT * FROM user WHERE id = ?
engine.ID(1).Delete(&user)
// UPDATE user SET ..., deleted_at = ? WHERE id = ?
engine.ID(1).Get(&user)
// Call Get again, this time it will return false, nil
engine.ID(1).Delete(&user)
// Call delete again, it will return 0, nil

But how to get this record if you really need retrieve it? You need Unscoped, for example:

var user User
engine.ID(1).Unscoped().Get(&user)
// Then you will return true, nil
engine.ID(1).Unscoped().Delete(&user)
// Then this record will be really deleted