Replace SQLite with BadgerDB

This commit is contained in:
David Stotijn
2022-01-21 11:45:54 +01:00
parent 8a3b3cbf02
commit d84d2d0905
49 changed files with 2496 additions and 2677 deletions

31
pkg/api/models.go Normal file
View File

@ -0,0 +1,31 @@
package api
import (
"fmt"
"io"
"strconv"
"github.com/oklog/ulid"
)
type ULID ulid.ULID
func (u *ULID) UnmarshalGQL(v interface{}) (err error) {
str, ok := v.(string)
if !ok {
return fmt.Errorf("ulid must be a string")
}
id, err := ulid.Parse(str)
if err != nil {
return fmt.Errorf("failed to parse ULID: %w", err)
}
*u = ULID(id)
return nil
}
func (u ULID) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(ulid.ULID(u).String()))
}