瀏覽代碼

model.DateTime

- add Scan
Alexey Kim 1 年之前
父節點
當前提交
a8be5a2d28
共有 1 個文件被更改,包括 10 次插入0 次删除
  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)
+}