field

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package field holds the field builders used to describe an entity schema.

Index

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) Field

func (*BoolField) Field()

marker method for sealed interface

func (*BoolField) GetContracts added in v0.0.3

func (f *BoolField) GetContracts() []entlite.Contract

GetContracts returns the layers the field belongs to.

func (*BoolField) GetDefault

func (f *BoolField) GetDefault() *bool

GetDefault returns the fixed default, or nil when there is none.

func (*BoolField) GetProtoField

func (f *BoolField) GetProtoField() *int

GetProtoField returns the pinned proto field number, or nil.

func (*BoolField) GetValidate

func (f *BoolField) GetValidate() func(bool) bool

GetValidate returns the validation function, or nil.

func (*BoolField) ProtoField

func (f *BoolField) ProtoField(num int) BoolFieldBuilder

func (*BoolField) Validate

func (f *BoolField) Validate(fn func(bool) bool) 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) Field

func (*ByteField) Field()

marker method for sealed interface

func (*ByteField) GetContracts added in v0.0.3

func (f *ByteField) GetContracts() []entlite.Contract

GetContracts returns the layers the field belongs to.

func (*ByteField) GetDefaultFunc

func (f *ByteField) GetDefaultFunc() func() []byte

GetDefaultFunc returns the default function, or nil when there is none.

func (*ByteField) GetImmutable

func (f *ByteField) GetImmutable() bool

GetImmutable reports if the field is immutable.

func (*ByteField) GetOptional

func (f *ByteField) GetOptional() bool

GetOptional reports if the field is optional.

func (*ByteField) GetProtoField

func (f *ByteField) GetProtoField() *int

GetProtoField returns the pinned proto field number, or nil.

func (*ByteField) GetUnique

func (f *ByteField) GetUnique() bool

GetUnique reports if the field is unique.

func (*ByteField) GetValidate

func (f *ByteField) GetValidate() func([]byte) bool

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

func (*ByteField) Validate

func (f *ByteField) Validate(fn func([]byte) bool) 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) Field

func (*FloatField) Field()

marker method for sealed interface

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) Field

func (*Int64Field) Field()

marker method for sealed interface

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) Field

func (*IntField) Field()

marker method for sealed interface

func (*IntField) GetContracts added in v0.0.3

func (f *IntField) GetContracts() []entlite.Contract

GetContracts returns the layers the field belongs to.

func (*IntField) GetDefault

func (f *IntField) GetDefault() *int32

GetDefault returns the fixed default, or nil when there is none.

func (*IntField) GetOptional

func (f *IntField) GetOptional() bool

GetOptional reports if the field is optional.

func (*IntField) GetProtoField

func (f *IntField) GetProtoField() *int

GetProtoField returns the pinned proto field number, or nil.

func (*IntField) GetValidate

func (f *IntField) GetValidate() func(int32) bool

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

func (*IntField) Validate

func (f *IntField) Validate(fn func(int32) bool) 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) Field

func (*JSONField) Field()

marker method for sealed interface

func (*JSONField) GetContracts added in v0.0.3

func (f *JSONField) GetContracts() []entlite.Contract

GetContracts returns the layers the field belongs to.

func (*JSONField) GetDefault

func (f *JSONField) GetDefault() *string

GetDefault returns the fixed default, or nil when there is none.

func (*JSONField) GetDefaultFunc

func (f *JSONField) GetDefaultFunc() func() string

GetDefaultFunc returns the default function, or nil when there is none.

func (*JSONField) GetImmutable

func (f *JSONField) GetImmutable() bool

GetImmutable reports if the field is immutable.

func (*JSONField) GetOptional

func (f *JSONField) GetOptional() bool

GetOptional reports if the field is optional.

func (*JSONField) GetProtoField

func (f *JSONField) GetProtoField() *int

GetProtoField returns the pinned proto field number, or nil.

func (*JSONField) GetValidate

func (f *JSONField) GetValidate() func(string) bool

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

func (*JSONField) Validate

func (f *JSONField) Validate(fn func(string) bool) 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) Field

func (*StringField) Field()

marker method for sealed interface

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) Default

func (f *TimeField) Default(value time.Time) TimeFieldBuilder

func (*TimeField) DefaultFunc

func (f *TimeField) DefaultFunc(fn func() time.Time) TimeFieldBuilder

func (*TimeField) Field

func (*TimeField) Field()

marker method for sealed interface

func (*TimeField) GetContracts added in v0.0.3

func (f *TimeField) GetContracts() []entlite.Contract

GetContracts returns the layers the field belongs to.

func (*TimeField) GetDefault

func (f *TimeField) GetDefault() *time.Time

GetDefault returns the fixed default, or nil when there is none.

func (*TimeField) GetDefaultFunc

func (f *TimeField) GetDefaultFunc() func() time.Time

GetDefaultFunc returns the default function, or nil when there is none.

func (*TimeField) GetImmutable

func (f *TimeField) GetImmutable() bool

GetImmutable reports if the field is immutable.

func (*TimeField) GetOptional

func (f *TimeField) GetOptional() bool

GetOptional reports if the field is optional.

func (*TimeField) GetProtoField

func (f *TimeField) GetProtoField() *int

GetProtoField returns the pinned proto field number, or nil.

func (*TimeField) GetValidate

func (f *TimeField) GetValidate() func(time.Time) bool

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

func (*TimeField) Validate

func (f *TimeField) Validate(fn func(time.Time) bool) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL