/
transactiontype.go
113 lines (100 loc) · 3.44 KB
/
transactiontype.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Code generated by ent, DO NOT EDIT.
package transactiontype
import (
"fmt"
"io"
"strconv"
"time"
"github.com/chenningg/hermitboard-api/pulid"
)
const (
// Label holds the string label denoting the transactiontype type in the database.
Label = "transaction_type"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldValue holds the string denoting the value field in the database.
FieldValue = "value"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// Table holds the table name of the transactiontype in the database.
Table = "transaction_types"
)
// Columns holds all SQL columns for transactiontype fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeletedAt,
FieldValue,
FieldDescription,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// UpdateDefaultDeletedAt holds the default value on update for the "deleted_at" field.
UpdateDefaultDeletedAt func() time.Time
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
DescriptionValidator func(string) error
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() pulid.PULID
)
// Value defines the type for the "value" enum field.
type Value string
// Value values.
const (
ValueBuy Value = "BUY"
ValueSell Value = "SELL"
ValueSwap Value = "SWAP"
ValueStake Value = "STAKE"
ValueDividendIncome Value = "DIVIDEND_INCOME"
ValueRentPayment Value = "RENT_PAYMENT"
ValueRentIncome Value = "RENT_INCOME"
ValueStockDividend Value = "STOCK_DIVIDEND"
)
func (v Value) String() string {
return string(v)
}
// ValueValidator is a validator for the "value" field enum values. It is called by the builders before save.
func ValueValidator(v Value) error {
switch v {
case ValueBuy, ValueSell, ValueSwap, ValueStake, ValueDividendIncome, ValueRentPayment, ValueRentIncome, ValueStockDividend:
return nil
default:
return fmt.Errorf("transactiontype: invalid enum value for value field: %q", v)
}
}
// MarshalGQL implements graphql.Marshaler interface.
func (e Value) MarshalGQL(w io.Writer) {
io.WriteString(w, strconv.Quote(e.String()))
}
// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *Value) UnmarshalGQL(val interface{}) error {
str, ok := val.(string)
if !ok {
return fmt.Errorf("enum %T must be a string", val)
}
*e = Value(str)
if err := ValueValidator(*e); err != nil {
return fmt.Errorf("%s is not a valid Value", str)
}
return nil
}