first commit
This commit is contained in:
22
server/db/base.go
Normal file
22
server/db/base.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
//Base is
|
||||
type Base struct {
|
||||
ID string `sql:"type:uuid;primary_key" json:"id"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt *time.Time `gorm:"index" json:"deletedAt"`
|
||||
}
|
||||
|
||||
//BeforeCreate
|
||||
func (base *Base) BeforeCreate(tx *gorm.DB) error {
|
||||
tx.Statement.SetColumn("ID", uuid.NewV4().String())
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user