Skip to content

Commit

Permalink
Stub GQL methods
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Oct 17, 2023
1 parent 0f52b2a commit 88caf2c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tl/tt/counts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 88caf2c

Please sign in to comment.