forked from turnkey-commerce/gendal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
booktype.xo.go
71 lines (54 loc) · 1.42 KB
/
booktype.xo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Package models contains the types for schema 'public'.
package models
// Code generated by xo. DO NOT EDIT.
import (
"database/sql/driver"
"errors"
)
// BookType is the 'book_type' enum type from schema 'public'.
type BookType uint16
const (
// BookTypeFiction is the 'FICTION' BookType.
BookTypeFiction = BookType(1)
// BookTypeNonfiction is the 'NONFICTION' BookType.
BookTypeNonfiction = BookType(2)
)
// String returns the string value of the BookType.
func (bt BookType) String() string {
var enumVal string
switch bt {
case BookTypeFiction:
enumVal = "FICTION"
case BookTypeNonfiction:
enumVal = "NONFICTION"
}
return enumVal
}
// MarshalText marshals BookType into text.
func (bt BookType) MarshalText() ([]byte, error) {
return []byte(bt.String()), nil
}
// UnmarshalText unmarshals BookType from text.
func (bt *BookType) UnmarshalText(text []byte) error {
switch string(text) {
case "FICTION":
*bt = BookTypeFiction
case "NONFICTION":
*bt = BookTypeNonfiction
default:
return errors.New("invalid BookType")
}
return nil
}
// Value satisfies the sql/driver.Valuer interface for BookType.
func (bt BookType) Value() (driver.Value, error) {
return bt.String(), nil
}
// Scan satisfies the database/sql.Scanner interface for BookType.
func (bt *BookType) Scan(src interface{}) error {
buf, ok := src.([]byte)
if !ok {
return errors.New("invalid BookType")
}
return bt.UnmarshalText(buf)
}