upd store
This commit is contained in:
6
models/common.go
Normal file
6
models/common.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package models
|
||||
|
||||
var (
|
||||
// Установка схемы (для баз, где они есть)
|
||||
SchemeName = ""
|
||||
)
|
||||
25
models/document.go
Normal file
25
models/document.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Document — логическая сущность (например, пользователь, настройки и т.п.)
|
||||
type Document struct {
|
||||
ID uuid.UUID `gorm:"type:char(36);primaryKey"`
|
||||
Name string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
LatestVersion uuid.UUID `gorm:"type:char(36);"`
|
||||
}
|
||||
|
||||
func (s *Document) TableName() (res string) {
|
||||
if SchemeName != "" {
|
||||
res = SchemeName + ".document"
|
||||
} else {
|
||||
res = "document"
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -7,15 +7,6 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Document — логическая сущность (например, пользователь, настройки и т.п.)
|
||||
type Document struct {
|
||||
ID uuid.UUID `gorm:"type:char(36);primaryKey"`
|
||||
Name string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
LatestVersion uuid.UUID `gorm:"type:char(36);"`
|
||||
}
|
||||
|
||||
// Version — конкретная версия документа
|
||||
type Version struct {
|
||||
ID uuid.UUID `gorm:"type:char(36);primaryKey"`
|
||||
@@ -26,3 +17,12 @@ type Version struct {
|
||||
Snapshot json.RawMessage `gorm:"type:json"` // Полный JSON, если IsSnapshot = true
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (s *Version) TableName() (res string) {
|
||||
if SchemeName != "" {
|
||||
res = SchemeName + ".version"
|
||||
} else {
|
||||
res = "version"
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user