Parcourir la source

model.DateTime

- add Scan
Alexey Kim il y a 1 an
Parent
commit
a8be5a2d28
1 fichiers modifiés avec 10 ajouts et 0 suppressions
  1. 10 0
      model/datetime.go

+ 10 - 0
model/datetime.go

@@ -2,6 +2,7 @@ package model
 
 import (
 	"encoding/json"
+	"fmt"
 	"io"
 	"log"
 	"regexp"
@@ -79,3 +80,12 @@ func (d *DateTime) UnmarshalGQL(v interface{}) error {
 
 	return nil
 }
+
+func (d *DateTime) Scan(src any) error {
+	if t, ok := src.(int64); ok {
+		*d = DateTime(t)
+		return nil
+	}
+
+	return fmt.Errorf("cannot scan %T into DateTime", src)
+}