From b6ba871a86797ad2f028eab2e3820509c3a36109 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 26 Mar 2026 02:12:10 +0700 Subject: lib/uuidv7: implements method Value from [driver.Valuer] The Value method returns the value for sending it to the database. --- lib/uuidv7/uuidv7.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/uuidv7/uuidv7.go b/lib/uuidv7/uuidv7.go index 6870b562..e35e684b 100644 --- a/lib/uuidv7/uuidv7.go +++ b/lib/uuidv7/uuidv7.go @@ -6,6 +6,7 @@ package uuidv7 import ( "crypto/rand" + "database/sql/driver" "encoding/binary" "encoding/hex" "fmt" @@ -217,3 +218,10 @@ func (id *UUIDv7) Time() time.Time { t := time.UnixMilli(int64(millis)) return t } + +// Value returns the value for sending it to the database. +// This method implements the [driver.Valuer] interface. +func (id UUIDv7) Value() (v driver.Value, err error) { + v = id.String() + return v, nil +} -- cgit v1.3