28 lines
539 B
Go
28 lines
539 B
Go
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}
|
|
}
|