From 88caf2c66aa4297745bdb9036a406b1fbebd1ae0 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Tue, 17 Oct 2023 14:48:01 -0400 Subject: [PATCH] Stub GQL methods --- tl/tt/counts.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tl/tt/counts.go b/tl/tt/counts.go index 3064be2f..9ca36336 100644 --- a/tl/tt/counts.go +++ b/tl/tt/counts.go @@ -4,19 +4,29 @@ import ( "database/sql/driver" "encoding/json" "errors" + "io" ) // Counts is a simple map[string]int with json support type Counts map[string]int -func (a Counts) Value() (driver.Value, error) { - return json.Marshal(a) +func (r Counts) Value() (driver.Value, error) { + return json.Marshal(r) } -func (a *Counts) Scan(value interface{}) error { +func (r *Counts) Scan(value interface{}) error { b, ok := value.([]byte) if !ok { return errors.New("type assertion to []byte failed") } - return json.Unmarshal(b, &a) + return json.Unmarshal(b, &r) +} + +func (r *Counts) UnmarshalGQL(v interface{}) error { + return r.Scan(v) +} + +func (r Counts) MarshalGQL(w io.Writer) { + // b, _ := r.MarshalJSON() + // w.Write(b) }