Module project, commit, submission
All checks were successful
Build and Release / release (push) Successful in 1m15s
All checks were successful
Build and Release / release (push) Successful in 1m15s
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
func GenerateQueryKey(prefix string, params any) string {
|
||||
b, _ := json.Marshal(params)
|
||||
hash := fmt.Sprintf("%x", md5.Sum(b))
|
||||
return fmt.Sprintf("%s:query:%s", prefix, hash)
|
||||
}
|
||||
|
||||
func UUIDToString(v pgtype.UUID) string {
|
||||
if v.Valid {
|
||||
return v.String()
|
||||
@@ -75,6 +84,16 @@ func PtrToText(s *string) pgtype.Text {
|
||||
}
|
||||
}
|
||||
|
||||
func StringToText(s string) pgtype.Text {
|
||||
if s == "" {
|
||||
return pgtype.Text{Valid: false}
|
||||
}
|
||||
return pgtype.Text{
|
||||
String: s,
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
func TextToPtr(v pgtype.Text) *string {
|
||||
if !v.Valid {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user