mirror of https://github.com/go-gorm/gorm.git
set updated_at and created_at with the same timestamp, prevent record from having slight difference between fields
This commit is contained in:
parent
452123479e
commit
c465d3214f
|
@ -13,8 +13,9 @@ func BeforeCreate(scope *Scope) {
|
||||||
|
|
||||||
func UpdateTimeStampWhenCreate(scope *Scope) {
|
func UpdateTimeStampWhenCreate(scope *Scope) {
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
scope.SetColumn("CreatedAt", time.Now())
|
now := time.Now()
|
||||||
scope.SetColumn("UpdatedAt", time.Now())
|
scope.SetColumn("CreatedAt", now)
|
||||||
|
scope.SetColumn("UpdatedAt", now)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue