Documentation
¶
Overview ¶
Package field holds the field builders used to describe an entity schema.
Index ¶
- type BoolField
- func (f *BoolField) Contracts(contracts ...entlite.Contract) BoolFieldBuilder
- func (f *BoolField) Default(value bool) BoolFieldBuilder
- func (*BoolField) Field()
- func (f *BoolField) GetContracts() []entlite.Contract
- func (f *BoolField) GetDefault() *bool
- func (f *BoolField) GetProtoField() *int
- func (f *BoolField) GetValidate() func(bool) bool
- func (f *BoolField) ProtoField(num int) BoolFieldBuilder
- func (f *BoolField) Validate(fn func(bool) bool) BoolFieldBuilder
- type BoolFieldBuilder
- type ByteField
- func (f *ByteField) Contracts(contracts ...entlite.Contract) ByteFieldBuilder
- func (f *ByteField) DefaultFunc(fn func() []byte) ByteFieldBuilder
- func (*ByteField) Field()
- func (f *ByteField) GetContracts() []entlite.Contract
- func (f *ByteField) GetDefaultFunc() func() []byte
- func (f *ByteField) GetImmutable() bool
- func (f *ByteField) GetOptional() bool
- func (f *ByteField) GetProtoField() *int
- func (f *ByteField) GetUnique() bool
- func (f *ByteField) GetValidate() func([]byte) bool
- func (f *ByteField) Immutable() ByteFieldBuilder
- func (f *ByteField) Optional() ByteFieldBuilder
- func (f *ByteField) ProtoField(num int) ByteFieldBuilder
- func (f *ByteField) Unique() ByteFieldBuilder
- func (f *ByteField) Validate(fn func([]byte) bool) ByteFieldBuilder
- type ByteFieldBuilder
- type FloatField
- func (f *FloatField) Contracts(contracts ...entlite.Contract) FloatFieldBuilder
- func (f *FloatField) Default(value float64) FloatFieldBuilder
- func (*FloatField) Field()
- func (f *FloatField) GetContracts() []entlite.Contract
- func (f *FloatField) GetDefault() *float64
- func (f *FloatField) GetOptional() bool
- func (f *FloatField) GetProtoField() *int
- func (f *FloatField) GetValidate() func(float64) bool
- func (f *FloatField) Optional() FloatFieldBuilder
- func (f *FloatField) ProtoField(num int) FloatFieldBuilder
- func (f *FloatField) Validate(fn func(float64) bool) FloatFieldBuilder
- type FloatFieldBuilder
- type Int64Field
- func (f *Int64Field) Contracts(contracts ...entlite.Contract) Int64FieldBuilder
- func (f *Int64Field) Default(value int64) Int64FieldBuilder
- func (*Int64Field) Field()
- func (f *Int64Field) GetContracts() []entlite.Contract
- func (f *Int64Field) GetDefault() *int64
- func (f *Int64Field) GetOptional() bool
- func (f *Int64Field) GetProtoField() *int
- func (f *Int64Field) GetValidate() func(int64) bool
- func (f *Int64Field) Optional() Int64FieldBuilder
- func (f *Int64Field) ProtoField(num int) Int64FieldBuilder
- func (f *Int64Field) Validate(fn func(int64) bool) Int64FieldBuilder
- type Int64FieldBuilder
- type IntField
- func (f *IntField) Contracts(contracts ...entlite.Contract) IntFieldBuilder
- func (f *IntField) Default(value int32) IntFieldBuilder
- func (*IntField) Field()
- func (f *IntField) GetContracts() []entlite.Contract
- func (f *IntField) GetDefault() *int32
- func (f *IntField) GetOptional() bool
- func (f *IntField) GetProtoField() *int
- func (f *IntField) GetValidate() func(int32) bool
- func (f *IntField) Optional() IntFieldBuilder
- func (f *IntField) ProtoField(num int) IntFieldBuilder
- func (f *IntField) Validate(fn func(int32) bool) IntFieldBuilder
- type IntFieldBuilder
- type JSONField
- func (f *JSONField) Contracts(contracts ...entlite.Contract) JSONFieldBuilder
- func (f *JSONField) Default(value string) JSONFieldBuilder
- func (f *JSONField) DefaultFunc(fn func() string) JSONFieldBuilder
- func (*JSONField) Field()
- func (f *JSONField) GetContracts() []entlite.Contract
- func (f *JSONField) GetDefault() *string
- func (f *JSONField) GetDefaultFunc() func() string
- func (f *JSONField) GetImmutable() bool
- func (f *JSONField) GetOptional() bool
- func (f *JSONField) GetProtoField() *int
- func (f *JSONField) GetValidate() func(string) bool
- func (f *JSONField) Immutable() JSONFieldBuilder
- func (f *JSONField) Optional() JSONFieldBuilder
- func (f *JSONField) ProtoField(num int) JSONFieldBuilder
- func (f *JSONField) Validate(fn func(string) bool) JSONFieldBuilder
- type JSONFieldBuilder
- type StringField
- func (f *StringField) Contracts(contracts ...entlite.Contract) StringFieldBuilder
- func (f *StringField) Default(value string) StringFieldBuilder
- func (f *StringField) DefaultFunc(fn func() string) StringFieldBuilder
- func (*StringField) Field()
- func (f *StringField) GetContracts() []entlite.Contract
- func (f *StringField) GetDefault() *string
- func (f *StringField) GetDefaultFunc() func() string
- func (f *StringField) GetImmutable() bool
- func (f *StringField) GetOptional() bool
- func (f *StringField) GetProtoField() *int
- func (f *StringField) GetUnique() bool
- func (f *StringField) GetValidate() func(string) bool
- func (f *StringField) Immutable() StringFieldBuilder
- func (f *StringField) Optional() StringFieldBuilder
- func (f *StringField) ProtoField(num int) StringFieldBuilder
- func (f *StringField) Unique() StringFieldBuilder
- func (f *StringField) Validate(fn func(string) bool) StringFieldBuilder
- type StringFieldBuilder
- type TimeField
- func (f *TimeField) Contracts(contracts ...entlite.Contract) TimeFieldBuilder
- func (f *TimeField) Default(value time.Time) TimeFieldBuilder
- func (f *TimeField) DefaultFunc(fn func() time.Time) TimeFieldBuilder
- func (*TimeField) Field()
- func (f *TimeField) GetContracts() []entlite.Contract
- func (f *TimeField) GetDefault() *time.Time
- func (f *TimeField) GetDefaultFunc() func() time.Time
- func (f *TimeField) GetImmutable() bool
- func (f *TimeField) GetOptional() bool
- func (f *TimeField) GetProtoField() *int
- func (f *TimeField) GetValidate() func(time.Time) bool
- func (f *TimeField) Immutable() TimeFieldBuilder
- func (f *TimeField) Optional() TimeFieldBuilder
- func (f *TimeField) ProtoField(num int) TimeFieldBuilder
- func (f *TimeField) Validate(fn func(time.Time) bool) TimeFieldBuilder
- type TimeFieldBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolField ¶
type BoolField struct {
// contains filtered or unexported fields
}
BoolField holds the state of a bool field.
func (*BoolField) Contracts ¶ added in v0.0.3
func (f *BoolField) Contracts(contracts ...entlite.Contract) BoolFieldBuilder
func (*BoolField) Default ¶
func (f *BoolField) Default(value bool) BoolFieldBuilder
func (*BoolField) GetContracts ¶ added in v0.0.3
GetContracts returns the layers the field belongs to.
func (*BoolField) GetDefault ¶
GetDefault returns the fixed default, or nil when there is none.
func (*BoolField) GetProtoField ¶
GetProtoField returns the pinned proto field number, or nil.
func (*BoolField) GetValidate ¶
GetValidate returns the validation function, or nil.
func (*BoolField) ProtoField ¶
func (f *BoolField) ProtoField(num int) BoolFieldBuilder
type BoolFieldBuilder ¶
type BoolFieldBuilder interface {
// Default sets a fixed default value.
Default(bool) BoolFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) BoolFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) BoolFieldBuilder
// Validate checks the value before it is written.
Validate(func(bool) bool) BoolFieldBuilder
// to satisfy entlite.Field interface
Field()
}
BoolFieldBuilder builds a bool field.
func Bool ¶
func Bool(name string) BoolFieldBuilder
Bool creates a bool field with the given column name.
type ByteField ¶
type ByteField struct {
// contains filtered or unexported fields
}
ByteField holds the state of a bytes field.
func (*ByteField) Contracts ¶ added in v0.0.3
func (f *ByteField) Contracts(contracts ...entlite.Contract) ByteFieldBuilder
func (*ByteField) DefaultFunc ¶
func (f *ByteField) DefaultFunc(fn func() []byte) ByteFieldBuilder
func (*ByteField) GetContracts ¶ added in v0.0.3
GetContracts returns the layers the field belongs to.
func (*ByteField) GetDefaultFunc ¶
GetDefaultFunc returns the default function, or nil when there is none.
func (*ByteField) GetImmutable ¶
GetImmutable reports if the field is immutable.
func (*ByteField) GetOptional ¶
GetOptional reports if the field is optional.
func (*ByteField) GetProtoField ¶
GetProtoField returns the pinned proto field number, or nil.
func (*ByteField) GetValidate ¶
GetValidate returns the validation function, or nil.
func (*ByteField) Immutable ¶
func (f *ByteField) Immutable() ByteFieldBuilder
func (*ByteField) Optional ¶
func (f *ByteField) Optional() ByteFieldBuilder
func (*ByteField) ProtoField ¶
func (f *ByteField) ProtoField(num int) ByteFieldBuilder
func (*ByteField) Unique ¶
func (f *ByteField) Unique() ByteFieldBuilder
type ByteFieldBuilder ¶
type ByteFieldBuilder interface {
// Unique makes the value unique across all rows.
Unique() ByteFieldBuilder
// Optional allows the column to be NULL.
Optional() ByteFieldBuilder
// Immutable blocks changes after the row is created.
Immutable() ByteFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) ByteFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) ByteFieldBuilder
// DefaultFunc sets a default value computed on insert.
DefaultFunc(func() []byte) ByteFieldBuilder
// Validate checks the value before it is written.
Validate(func([]byte) bool) ByteFieldBuilder
// to satisfy entlite.Field interface
Field()
}
ByteFieldBuilder builds a raw bytes field.
func Byte ¶
func Byte(name string) ByteFieldBuilder
Byte creates a bytes field with the given column name.
type FloatField ¶
type FloatField struct {
// contains filtered or unexported fields
}
FloatField holds the state of a float64 field.
func (*FloatField) Contracts ¶ added in v0.0.3
func (f *FloatField) Contracts(contracts ...entlite.Contract) FloatFieldBuilder
func (*FloatField) Default ¶
func (f *FloatField) Default(value float64) FloatFieldBuilder
func (*FloatField) GetContracts ¶ added in v0.0.3
func (f *FloatField) GetContracts() []entlite.Contract
GetContracts returns the layers the field belongs to.
func (*FloatField) GetDefault ¶
func (f *FloatField) GetDefault() *float64
GetDefault returns the fixed default, or nil when there is none.
func (*FloatField) GetOptional ¶
func (f *FloatField) GetOptional() bool
GetOptional reports if the field is optional.
func (*FloatField) GetProtoField ¶
func (f *FloatField) GetProtoField() *int
GetProtoField returns the pinned proto field number, or nil.
func (*FloatField) GetValidate ¶
func (f *FloatField) GetValidate() func(float64) bool
GetValidate returns the validation function, or nil.
func (*FloatField) Optional ¶
func (f *FloatField) Optional() FloatFieldBuilder
func (*FloatField) ProtoField ¶
func (f *FloatField) ProtoField(num int) FloatFieldBuilder
func (*FloatField) Validate ¶
func (f *FloatField) Validate(fn func(float64) bool) FloatFieldBuilder
type FloatFieldBuilder ¶
type FloatFieldBuilder interface {
// Default sets a fixed default value.
Default(float64) FloatFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) FloatFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) FloatFieldBuilder
// Optional allows the column to be NULL.
Optional() FloatFieldBuilder
// Validate checks the value before it is written.
Validate(func(float64) bool) FloatFieldBuilder
// to satisfy entlite.Field interface
Field()
}
FloatFieldBuilder builds a float64 field.
func Float ¶
func Float(name string) FloatFieldBuilder
Float creates a float64 field with the given column name.
type Int64Field ¶
type Int64Field struct {
// contains filtered or unexported fields
}
Int64Field holds the state of an int64 field.
func (*Int64Field) Contracts ¶ added in v0.0.3
func (f *Int64Field) Contracts(contracts ...entlite.Contract) Int64FieldBuilder
func (*Int64Field) Default ¶
func (f *Int64Field) Default(value int64) Int64FieldBuilder
func (*Int64Field) GetContracts ¶ added in v0.0.3
func (f *Int64Field) GetContracts() []entlite.Contract
GetContracts returns the layers the field belongs to.
func (*Int64Field) GetDefault ¶
func (f *Int64Field) GetDefault() *int64
GetDefault returns the fixed default, or nil when there is none.
func (*Int64Field) GetOptional ¶
func (f *Int64Field) GetOptional() bool
GetOptional reports if the field is optional.
func (*Int64Field) GetProtoField ¶
func (f *Int64Field) GetProtoField() *int
GetProtoField returns the pinned proto field number, or nil.
func (*Int64Field) GetValidate ¶
func (f *Int64Field) GetValidate() func(int64) bool
GetValidate returns the validation function, or nil.
func (*Int64Field) Optional ¶
func (f *Int64Field) Optional() Int64FieldBuilder
func (*Int64Field) ProtoField ¶
func (f *Int64Field) ProtoField(num int) Int64FieldBuilder
func (*Int64Field) Validate ¶
func (f *Int64Field) Validate(fn func(int64) bool) Int64FieldBuilder
type Int64FieldBuilder ¶
type Int64FieldBuilder interface {
// Default sets a fixed default value.
Default(int64) Int64FieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) Int64FieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) Int64FieldBuilder
// Optional allows the column to be NULL.
Optional() Int64FieldBuilder
// Validate checks the value before it is written.
Validate(func(int64) bool) Int64FieldBuilder
// to satisfy entlite.Field interface
Field()
}
Int64FieldBuilder builds an int64 field.
func Int64 ¶
func Int64(name string) Int64FieldBuilder
Int64 creates an int64 field with the given column name.
type IntField ¶
type IntField struct {
// contains filtered or unexported fields
}
IntField holds the state of an int field.
func (*IntField) Contracts ¶ added in v0.0.3
func (f *IntField) Contracts(contracts ...entlite.Contract) IntFieldBuilder
func (*IntField) Default ¶
func (f *IntField) Default(value int32) IntFieldBuilder
func (*IntField) GetContracts ¶ added in v0.0.3
GetContracts returns the layers the field belongs to.
func (*IntField) GetDefault ¶
GetDefault returns the fixed default, or nil when there is none.
func (*IntField) GetOptional ¶
GetOptional reports if the field is optional.
func (*IntField) GetProtoField ¶
GetProtoField returns the pinned proto field number, or nil.
func (*IntField) GetValidate ¶
GetValidate returns the validation function, or nil.
func (*IntField) Optional ¶
func (f *IntField) Optional() IntFieldBuilder
func (*IntField) ProtoField ¶
func (f *IntField) ProtoField(num int) IntFieldBuilder
type IntFieldBuilder ¶
type IntFieldBuilder interface {
// Default sets a fixed default value.
Default(int32) IntFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) IntFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) IntFieldBuilder
// Optional allows the column to be NULL.
Optional() IntFieldBuilder
// Validate checks the value before it is written.
Validate(func(int32) bool) IntFieldBuilder
// to satisfy entlite.Field interface
Field()
}
IntFieldBuilder builds an int field. int is int32, to match a JS number.
func Int ¶
func Int(name string) IntFieldBuilder
Int creates an int32 field with the given column name.
type JSONField ¶
type JSONField struct {
// contains filtered or unexported fields
}
JSONField holds the state of a json field.
func (*JSONField) Contracts ¶ added in v0.0.3
func (f *JSONField) Contracts(contracts ...entlite.Contract) JSONFieldBuilder
func (*JSONField) Default ¶
func (f *JSONField) Default(value string) JSONFieldBuilder
func (*JSONField) DefaultFunc ¶
func (f *JSONField) DefaultFunc(fn func() string) JSONFieldBuilder
func (*JSONField) GetContracts ¶ added in v0.0.3
GetContracts returns the layers the field belongs to.
func (*JSONField) GetDefault ¶
GetDefault returns the fixed default, or nil when there is none.
func (*JSONField) GetDefaultFunc ¶
GetDefaultFunc returns the default function, or nil when there is none.
func (*JSONField) GetImmutable ¶
GetImmutable reports if the field is immutable.
func (*JSONField) GetOptional ¶
GetOptional reports if the field is optional.
func (*JSONField) GetProtoField ¶
GetProtoField returns the pinned proto field number, or nil.
func (*JSONField) GetValidate ¶
GetValidate returns the validation function, or nil.
func (*JSONField) Immutable ¶
func (f *JSONField) Immutable() JSONFieldBuilder
func (*JSONField) Optional ¶
func (f *JSONField) Optional() JSONFieldBuilder
func (*JSONField) ProtoField ¶
func (f *JSONField) ProtoField(num int) JSONFieldBuilder
type JSONFieldBuilder ¶
type JSONFieldBuilder interface {
// Optional allows the column to be NULL.
Optional() JSONFieldBuilder
// Immutable blocks changes after the row is created.
Immutable() JSONFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) JSONFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) JSONFieldBuilder
// Default takes raw json text, e.g. `{}` or `{"theme":"dark"}`
Default(string) JSONFieldBuilder
// DefaultFunc sets a default value computed on insert, it clears Default.
DefaultFunc(func() string) JSONFieldBuilder
// Validate checks the value before it is written.
Validate(func(string) bool) JSONFieldBuilder
// to satisfy entlite.Field interface
Field()
}
JSONFieldBuilder builds a json field, stored as text.
func JSON ¶
func JSON(name string) JSONFieldBuilder
JSON creates a json field with the given column name.
type StringField ¶
type StringField struct {
// contains filtered or unexported fields
}
StringField holds the state of a string field.
func (*StringField) Contracts ¶ added in v0.0.3
func (f *StringField) Contracts(contracts ...entlite.Contract) StringFieldBuilder
func (*StringField) Default ¶
func (f *StringField) Default(value string) StringFieldBuilder
func (*StringField) DefaultFunc ¶
func (f *StringField) DefaultFunc(fn func() string) StringFieldBuilder
func (*StringField) GetContracts ¶ added in v0.0.3
func (f *StringField) GetContracts() []entlite.Contract
GetContracts returns the layers the field belongs to.
func (*StringField) GetDefault ¶
func (f *StringField) GetDefault() *string
GetDefault returns the fixed default, or nil when there is none.
func (*StringField) GetDefaultFunc ¶
func (f *StringField) GetDefaultFunc() func() string
GetDefaultFunc returns the default function, or nil when there is none.
func (*StringField) GetImmutable ¶
func (f *StringField) GetImmutable() bool
GetImmutable reports if the field is immutable.
func (*StringField) GetOptional ¶
func (f *StringField) GetOptional() bool
GetOptional reports if the field is optional.
func (*StringField) GetProtoField ¶
func (f *StringField) GetProtoField() *int
GetProtoField returns the pinned proto field number, or nil.
func (*StringField) GetUnique ¶
func (f *StringField) GetUnique() bool
GetUnique reports if the field is unique.
func (*StringField) GetValidate ¶
func (f *StringField) GetValidate() func(string) bool
GetValidate returns the validation function, or nil.
func (*StringField) Immutable ¶
func (f *StringField) Immutable() StringFieldBuilder
func (*StringField) Optional ¶
func (f *StringField) Optional() StringFieldBuilder
func (*StringField) ProtoField ¶
func (f *StringField) ProtoField(num int) StringFieldBuilder
func (*StringField) Unique ¶
func (f *StringField) Unique() StringFieldBuilder
setters with chaining logic. uses mutable struct
func (*StringField) Validate ¶
func (f *StringField) Validate(fn func(string) bool) StringFieldBuilder
type StringFieldBuilder ¶
type StringFieldBuilder interface {
// Unique makes the value unique across all rows.
Unique() StringFieldBuilder
// Default sets a fixed default value, it clears DefaultFunc.
Default(string) StringFieldBuilder
// DefaultFunc sets a default value computed on insert, it clears Default.
DefaultFunc(func() string) StringFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) StringFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) StringFieldBuilder
// Immutable blocks changes after the row is created.
Immutable() StringFieldBuilder
// Optional allows the column to be NULL.
Optional() StringFieldBuilder
// Validate checks the value before it is written.
Validate(func(string) bool) StringFieldBuilder
// to satisfy entlite.Field interface
Field()
}
StringFieldBuilder builds a string field.
func String ¶
func String(name string) StringFieldBuilder
String creates a string field with the given column name.
type TimeField ¶
type TimeField struct {
// contains filtered or unexported fields
}
TimeField holds the state of a time field.
func (*TimeField) Contracts ¶ added in v0.0.3
func (f *TimeField) Contracts(contracts ...entlite.Contract) TimeFieldBuilder
func (*TimeField) DefaultFunc ¶
func (f *TimeField) DefaultFunc(fn func() time.Time) TimeFieldBuilder
func (*TimeField) GetContracts ¶ added in v0.0.3
GetContracts returns the layers the field belongs to.
func (*TimeField) GetDefault ¶
GetDefault returns the fixed default, or nil when there is none.
func (*TimeField) GetDefaultFunc ¶
GetDefaultFunc returns the default function, or nil when there is none.
func (*TimeField) GetImmutable ¶
GetImmutable reports if the field is immutable.
func (*TimeField) GetOptional ¶
GetOptional reports if the field is optional.
func (*TimeField) GetProtoField ¶
GetProtoField returns the pinned proto field number, or nil.
func (*TimeField) GetValidate ¶
GetValidate returns the validation function, or nil.
func (*TimeField) Immutable ¶
func (f *TimeField) Immutable() TimeFieldBuilder
func (*TimeField) Optional ¶
func (f *TimeField) Optional() TimeFieldBuilder
func (*TimeField) ProtoField ¶
func (f *TimeField) ProtoField(num int) TimeFieldBuilder
type TimeFieldBuilder ¶
type TimeFieldBuilder interface {
// Default sets a fixed default value, it clears DefaultFunc.
Default(time.Time) TimeFieldBuilder
// DefaultFunc sets a default value computed on insert, it clears Default.
DefaultFunc(func() time.Time) TimeFieldBuilder
// ProtoField pins the proto field number, so it stays stable.
ProtoField(int) TimeFieldBuilder
// Contracts limits the field to the given layers, sqlc or proto.
Contracts(contracts ...entlite.Contract) TimeFieldBuilder
// Immutable blocks changes after the row is created.
Immutable() TimeFieldBuilder
// Optional allows the column to be NULL.
Optional() TimeFieldBuilder
// Validate checks the value before it is written.
Validate(func(time.Time) bool) TimeFieldBuilder
// to satisfy entlite.Field interface
Field()
}
TimeFieldBuilder builds a timestamp field.
func Time ¶
func Time(name string) TimeFieldBuilder
Time creates a timestamp field with the given column name.