initial commit
This commit is contained in:
27
internal/service/helpers.go
Normal file
27
internal/service/helpers.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
// Helper functions для конвертации типов Go в pgtype
|
||||
|
||||
func stringToPgText(s string) pgtype.Text {
|
||||
if s == "" {
|
||||
return pgtype.Text{Valid: false}
|
||||
}
|
||||
return pgtype.Text{String: s, Valid: true}
|
||||
}
|
||||
|
||||
func int64ToPgInt8(i int64) pgtype.Int8 {
|
||||
if i == 0 {
|
||||
return pgtype.Int8{Valid: false}
|
||||
}
|
||||
return pgtype.Int8{Int64: i, Valid: true}
|
||||
}
|
||||
|
||||
func timeToPgTimestamptz(t time.Time) pgtype.Timestamptz {
|
||||
return pgtype.Timestamptz{Time: t, Valid: true}
|
||||
}
|
||||
Reference in New Issue
Block a user