mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: added hash to models
This commit is contained in:
@@ -24,6 +24,7 @@ type DatabaseColumn struct {
|
||||
Default string `json:"default,omitempty"`
|
||||
Extra string `json:"extra,omitempty"`
|
||||
Children []DatabaseColumn `json:"children,omitempty"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
}
|
||||
|
||||
type DatabaseIndex struct {
|
||||
@@ -31,6 +32,7 @@ type DatabaseIndex struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Columns []DatabaseIndexColumn `json:"columns"`
|
||||
Unique bool `json:"unique"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
}
|
||||
|
||||
type DatabaseIndexColumn struct {
|
||||
|
||||
12
core/utils/hash.go
Normal file
12
core/utils/hash.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package utils
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func GetObjectHash(obj any) string {
|
||||
data, _ := json.Marshal(obj)
|
||||
if data == nil {
|
||||
// random hash
|
||||
return EncryptMd5(NewUUIDString())
|
||||
}
|
||||
return EncryptMd5(string(data))
|
||||
}
|
||||
Reference in New Issue
Block a user