Files
hammond/server/db/base.go
Akhil Gupta d25c30a7b2 first commit
2021-05-29 15:20:50 +05:30

23 lines
447 B
Go

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
}