Sfoglia il codice sorgente

model.DateTime

- add Scan
Alexey Kim 1 anno fa
parent
commit
a8be5a2d28
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  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)
+}