remove uuid
This commit is contained in:
14
db/base.go
14
db/base.go
@@ -2,9 +2,6 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
|
||||||
"github.com/twinj/uuid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CrudBase struct {
|
type CrudBase struct {
|
||||||
@@ -22,14 +19,3 @@ type Base struct {
|
|||||||
IDBase
|
IDBase
|
||||||
CrudBase
|
CrudBase
|
||||||
}
|
}
|
||||||
|
|
||||||
// BaseWithUUID is the base model with an UUIDv4 primary key
|
|
||||||
type BaseWithUUID struct {
|
|
||||||
IDBase
|
|
||||||
CrudBase
|
|
||||||
}
|
|
||||||
|
|
||||||
// BeforeCreate is called by GORM to set the UUID primary key
|
|
||||||
func (b *BaseWithUUID) BeforeCreate(scope *gorm.Scope) error {
|
|
||||||
return scope.SetColumn("ID", uuid.NewV4().String())
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user