Documentation
¶
Index ¶
- func BytesToSlice(dest any, src []byte) error
- type BaseBuilder
- func (b *BaseBuilder[T]) AttrType(dbType dialect.DbDriver) string
- func (b *BaseBuilder[T]) Check(builder CheckBuilder) *BaseBuilder[T]
- func (b *BaseBuilder[T]) Descriptor() *entity.Descriptor
- func (b *BaseBuilder[T]) ExtTemplate() []string
- func (b *BaseBuilder[T]) Index(index int) *BaseBuilder[T]
- func (b *BaseBuilder[T]) IndexMethod(method string) *BaseBuilder[T]
- func (b *BaseBuilder[T]) IndexName(name string) *BaseBuilder[T]
- func (b *BaseBuilder[T]) Init(desc *entity.Descriptor) error
- func (b *BaseBuilder[T]) SetValueType(valueType string) *BaseBuilder[T]
- func (b *BaseBuilder[T]) Unique(index int) *BaseBuilder[T]
- func (b *BaseBuilder[T]) ValueType() string
- type BaseStorage
- func (b *BaseStorage[T]) Get() *T
- func (i *BaseStorage[T]) MarshalJSON() ([]byte, error)
- func (b *BaseStorage[T]) Scan(value interface{}) error
- func (b *BaseStorage[T]) Set(value T) error
- func (i *BaseStorage[T]) SqlFormatParam() func(dbType dialect.DbDriver, param string) string
- func (i *BaseStorage[T]) SqlParam(dbType dialect.DbDriver) (entity.FieldValue, error)
- func (i *BaseStorage[T]) SqlSelectFormat() func(dbType dialect.DbDriver, name string) string
- func (b BaseStorage[T]) String() string
- type Bool
- type BoolA1
- type BoolA2
- type BoolA3
- type BoolA4
- type BoolA5
- type BoolBuilder
- func (i *BoolBuilder[T]) Comment(comment string) *BoolBuilder[T]
- func (i *BoolBuilder[T]) Default(value bool) *BoolBuilder[T]
- func (i *BoolBuilder[T]) Locked() *BoolBuilder[T]
- func (i *BoolBuilder[T]) Name(name string) *BoolBuilder[T]
- func (i *BoolBuilder[T]) Primary(index int) *BoolBuilder[T]
- func (i *BoolBuilder[T]) Required() *BoolBuilder[T]
- func (i *BoolBuilder[T]) Unique(index int) *BoolBuilder[T]
- type BoolStorage
- type CheckBuilder
- type Int16
- type Int16A1
- type Int16A2
- type Int16A3
- type Int16A4
- type Int16A5
- type Int32
- type Int32A1
- type Int32A2
- type Int32A3
- type Int32A4
- type Int32A5
- type Int64
- type Int64A1
- type Int64A2
- type Int64A3
- type Int64A4
- type Int64A5
- type IntBuilder
- func (i *IntBuilder[T]) Comment(comment string) *IntBuilder[T]
- func (i *IntBuilder[T]) Default(value T) *IntBuilder[T]
- func (i *IntBuilder[T]) Locked() *IntBuilder[T]
- func (i *IntBuilder[T]) MinLen(size int) *IntBuilder[T]
- func (i *IntBuilder[T]) Name(name string) *IntBuilder[T]
- func (i *IntBuilder[T]) Primary(index int) *IntBuilder[T]
- func (i *IntBuilder[T]) Required() *IntBuilder[T]
- func (i *IntBuilder[T]) Sequence(s entity.Sequence) *IntBuilder[T]
- func (i *IntBuilder[T]) Unique(index int) *IntBuilder[T]
- type IntStorage
- type RawBytes
- type Scanner
- type StringStorage
- type Text
- type TextBuilder
- func (s *TextBuilder[T]) AttrType(dbType dialect.DbDriver) string
- func (s *TextBuilder[T]) Comment(comment string) *TextBuilder[T]
- func (s *TextBuilder[T]) Default(value string) *TextBuilder[T]
- func (s *TextBuilder[T]) Locked() *TextBuilder[T]
- func (s *TextBuilder[T]) MinLen(i int) *TextBuilder[T]
- func (s *TextBuilder[T]) Name(name string) *TextBuilder[T]
- func (s *TextBuilder[T]) Primary(index int) *TextBuilder[T]
- func (s *TextBuilder[T]) Required() *TextBuilder[T]
- func (s *TextBuilder[T]) Unique(index int) *TextBuilder[T]
- type TimestampStorage
- type Timestamptz
- type TimestamptzA1
- type TimestamptzA2
- type TimestamptzA3
- type TimestamptzA4
- type TimestamptzA5
- type TimestamptzBuilder
- func (t *TimestamptzBuilder[T]) AttrType(dbType dialect.DbDriver) string
- func (t *TimestamptzBuilder[T]) Comment(comment string) *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Default(value string) *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Init(desc *entity.Descriptor) error
- func (t *TimestamptzBuilder[T]) Locked() *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) MinLen(size int) *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Name(name string) *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Precision(precision int) *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Primary(index int) *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Required() *TimestamptzBuilder[T]
- func (t *TimestamptzBuilder[T]) Unique(index int) *TimestamptzBuilder[T]
- type UUID
- type UUIDA1
- type UUIDBuilder
- func (u *UUIDBuilder[T]) AttrType(dbType dialect.DbDriver) string
- func (u *UUIDBuilder[T]) Comment(comment string) *UUIDBuilder[T]
- func (u *UUIDBuilder[T]) Default(value *string) *UUIDBuilder[T]
- func (u *UUIDBuilder[T]) Locked() *UUIDBuilder[T]
- func (u *UUIDBuilder[T]) Name(name string) *UUIDBuilder[T]
- func (u *UUIDBuilder[T]) Primary(index int) *UUIDBuilder[T]
- func (u *UUIDBuilder[T]) Required() *UUIDBuilder[T]
- func (u *UUIDBuilder[T]) Unique(index int) *UUIDBuilder[T]
- type Varchar
- type VarcharA1
- type VarcharA2
- type VarcharA3
- type VarcharA4
- type VarcharA5
- type VarcharBuilder
- func (s *VarcharBuilder[T]) AttrType(dbType dialect.DbDriver) string
- func (s *VarcharBuilder[T]) Comment(comment string) *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) Default(value string) *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) Locked() *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) MaxLen(i int64) *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) MinLen(i int) *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) Name(name string) *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) Primary(index int) *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) Required() *VarcharBuilder[T]
- func (s *VarcharBuilder[T]) Unique(index int) *VarcharBuilder[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseBuilder ¶
type BaseBuilder[T any] struct { // contains filtered or unexported fields }
func (*BaseBuilder[T]) AttrType ¶
func (b *BaseBuilder[T]) AttrType(dbType dialect.DbDriver) string
AttrType 获取字段的数据库中的类型名,如果返回空字符串,会出现错误。
Params:
- dbType: 数据库类型。
Returns:
- 字段的数据库中的类型名。
func (*BaseBuilder[T]) Check ¶
func (b *BaseBuilder[T]) Check(builder CheckBuilder) *BaseBuilder[T]
Check 添加CHECK约束到字段 参数 builder 是一个回调函数,接收字段名并返回CHECK约束的内容
func (*BaseBuilder[T]) Descriptor ¶
func (b *BaseBuilder[T]) Descriptor() *entity.Descriptor
Descriptor 获取字段的描述信息。
func (*BaseBuilder[T]) ExtTemplate ¶
func (b *BaseBuilder[T]) ExtTemplate() []string
ExtTemplate 用于在使用字段时,调用外部模版生成代码, 这个相比在 go run github.com/zodileap/taurus_go/entity/cmd generate -t <template>, `ExtTemplate`是和字段相关联,只要调用字段就会生成代码,避免了每次都要手动调用模版。
func (*BaseBuilder[T]) Index ¶
func (b *BaseBuilder[T]) Index(index int) *BaseBuilder[T]
Index 设置字段为索引。
func (*BaseBuilder[T]) IndexMethod ¶
func (b *BaseBuilder[T]) IndexMethod(method string) *BaseBuilder[T]
IndexMethod 设置索引方法。
Params:
- method: 索引方法,如"btree","hash"等。
func (*BaseBuilder[T]) IndexName ¶
func (b *BaseBuilder[T]) IndexName(name string) *BaseBuilder[T]
IndexName 设置索引名称。
Params:
- name: 索引名称。
func (*BaseBuilder[T]) Init ¶
func (b *BaseBuilder[T]) Init(desc *entity.Descriptor) error
Init 初始化字段的描述信息,在代码生成阶段初始化时调用。
Params:
- desc: 字段的描述信息。
func (*BaseBuilder[T]) SetValueType ¶
func (b *BaseBuilder[T]) SetValueType(valueType string) *BaseBuilder[T]
SetValueType 设置字段的值在go中类型名称。
Params:
- valueType: 字段的值在go中类型名称。
func (*BaseBuilder[T]) Unique ¶
func (b *BaseBuilder[T]) Unique(index int) *BaseBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。
func (*BaseBuilder[T]) ValueType ¶
func (b *BaseBuilder[T]) ValueType() string
ValueType 用于设置字段的值在go中类型名称。例如entity.Int64的ValueType为"int64"。
Returns:
- 字段的值在go中类型名称。
type BaseStorage ¶
type BaseStorage[T any] struct { // contains filtered or unexported fields }
func (*BaseStorage[T]) MarshalJSON ¶
func (i *BaseStorage[T]) MarshalJSON() ([]byte, error)
MarshalJSON 用于将字段的值转换为JSON格式。
func (*BaseStorage[T]) Scan ¶
func (b *BaseStorage[T]) Scan(value interface{}) error
Scan 从数据库中读取字段的值。
func (*BaseStorage[T]) SqlFormatParam ¶
func (i *BaseStorage[T]) SqlFormatParam() func(dbType dialect.DbDriver, param string) string
SqlFormatParam 用于sql中获取字段的值的格式化字符串。如 INSERT INTO "blog" ( "desc" ) VALUES ( ST_GeomFromGeoJSON($1) ) 中添加的ST_GeomFromGeoJSON()。
func (*BaseStorage[T]) SqlParam ¶
func (i *BaseStorage[T]) SqlParam(dbType dialect.DbDriver) (entity.FieldValue, error)
SqlParam 用于sql中获取字段参数并赋值。如 INSERT INTO "blog" ( "desc") VALUES ($1),给$1传递具体的值。
func (*BaseStorage[T]) SqlSelectFormat ¶
func (i *BaseStorage[T]) SqlSelectFormat() func(dbType dialect.DbDriver, name string) string
SqlSelectClause 用于sql语句中获取字段的select子句部分,通过这个能够扩展SELECT部分实现复杂的查询,比如 SELECT id, ST_AsText(point)。
type BoolA1 ¶
type BoolA1 struct {
BoolBuilder[[]bool]
BoolStorage[[]bool]
}
type BoolA2 ¶
type BoolA2 struct {
BoolBuilder[[][]bool]
BoolStorage[[][]bool]
}
type BoolA3 ¶
type BoolA3 struct {
BoolBuilder[[][][]bool]
BoolStorage[[][][]bool]
}
type BoolA4 ¶
type BoolA4 struct {
BoolBuilder[[][][][]bool]
BoolStorage[[][][][]bool]
}
type BoolA5 ¶
type BoolA5 struct {
BoolBuilder[[][][][][]bool]
BoolStorage[[][][][][]bool]
}
type BoolBuilder ¶
type BoolBuilder[T any] struct { BaseBuilder[T] }
BoolBuilder 布尔类型的字段构建器。
func (*BoolBuilder[T]) Comment ¶
func (i *BoolBuilder[T]) Comment(comment string) *BoolBuilder[T]
Comment 设置字段的注释。
Params:
- comment: 字段的注释。
func (*BoolBuilder[T]) Default ¶
func (i *BoolBuilder[T]) Default(value bool) *BoolBuilder[T]
Default 设置字段的默认值。 如果设置了默认值,则在插入数据时,如果没有设置字段的值,则会使用默认值。
Params:
- value: 字段的默认值。
func (*BoolBuilder[T]) Name ¶
func (i *BoolBuilder[T]) Name(name string) *BoolBuilder[T]
Name 用于设置字段在数据库中的名称。
如果不设置,会默认采用`snake_case`的方式将字段名转换为数据库字段名,比如示例中的ID字段会被转换为`i_d`。
Params:
- name: 字段在数据库中的名称。
func (*BoolBuilder[T]) Primary ¶
func (i *BoolBuilder[T]) Primary(index int) *BoolBuilder[T]
Primary设置字段为主键。
Params:
- index: 主键的索引,从1开始,对于多个主键,需要设置不同大小的索引。
func (*BoolBuilder[T]) Required ¶
func (i *BoolBuilder[T]) Required() *BoolBuilder[T]
Required 是否非空,默认可以为null,如果调用[Required],则字段为非空字段。
func (*BoolBuilder[T]) Unique ¶ added in v0.9.15
func (i *BoolBuilder[T]) Unique(index int) *BoolBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。
type Int16A1 ¶
type Int16A1 struct {
IntBuilder[[]int16]
IntStorage[[]int16]
}
Int16A1 用于定义int16类型的数组字段。1维数组。
type Int16A2 ¶
type Int16A2 struct {
IntBuilder[[][]int16]
IntStorage[[][]int16]
}
Int16A2 用于定义int16类型的数组字段。2维数组。
type Int16A3 ¶
type Int16A3 struct {
IntBuilder[[][][]int16]
IntStorage[[][][]int16]
}
Int16A3 用于定义int16类型的数组字段。3维数组。
type Int16A4 ¶
type Int16A4 struct {
IntBuilder[[][][][]int16]
IntStorage[[][][][]int16]
}
Int16A4 用于定义int16类型的数组字段。4维数组。
type Int16A5 ¶
type Int16A5 struct {
IntBuilder[[][][][][]int16]
IntStorage[[][][][][]int16]
}
Int16A5 用于定义int16类型的数组字段。5维数组。
type Int32A1 ¶
type Int32A1 struct {
IntBuilder[[]int32]
IntStorage[[]int32]
}
Int32A1 用于定义int32类型的数组字段。1维数组。
type Int32A2 ¶
type Int32A2 struct {
IntBuilder[[][]int32]
IntStorage[[][]int32]
}
Int32A2 用于定义int32类型的数组字段。2维数组。
type Int32A3 ¶
type Int32A3 struct {
IntBuilder[[][][]int32]
IntStorage[[][][]int32]
}
Int32A3 用于定义int32类型的数组字段。3维数组。
type Int32A4 ¶
type Int32A4 struct {
IntBuilder[[][][][]int32]
IntStorage[[][][][]int32]
}
Int32A4 用于定义int32类型的数组字段。4维数组。
type Int32A5 ¶
type Int32A5 struct {
IntBuilder[[][][][][]int32]
IntStorage[[][][][][]int32]
}
Int32A5 用于定义int32类型的数组字段。5维数组。
type Int64A1 ¶
type Int64A1 struct {
IntBuilder[[]int64]
IntStorage[[]int64]
}
Int64A1 用于定义int64类型的数组字段。1维数组。
type Int64A2 ¶
type Int64A2 struct {
IntBuilder[[][]int64]
IntStorage[[][]int64]
}
Int64A2 用于定义int64类型的数组字段。2维数组。
type Int64A3 ¶
type Int64A3 struct {
IntBuilder[[][][]int64]
IntStorage[[][][]int64]
}
Int64A3 用于定义int64类型的数组字段。3维数组。
type Int64A4 ¶
type Int64A4 struct {
IntBuilder[[][][][]int64]
IntStorage[[][][][]int64]
}
Int64A4 用于定义int64类型的数组字段。4维数组。
type Int64A5 ¶
type Int64A5 struct {
IntBuilder[[][][][][]int64]
IntStorage[[][][][][]int64]
}
Int64A5 用于定义int64类型的数组字段。5维数组。
type IntBuilder ¶
type IntBuilder[T any] struct { BaseBuilder[T] }
IntBuilder 用于构建int类型的字段。
func (*IntBuilder[T]) Comment ¶
func (i *IntBuilder[T]) Comment(comment string) *IntBuilder[T]
Comment 设置字段的注释。
Params:
- comment: 字段的注释。
func (*IntBuilder[T]) Default ¶
func (i *IntBuilder[T]) Default(value T) *IntBuilder[T]
Default 设置字段的默认值。 如果设置了默认值,则在插入数据时,如果没有设置字段的值,则会使用默认值。
Params:
- value: 字段的默认值。
func (*IntBuilder[T]) MinLen ¶
func (i *IntBuilder[T]) MinLen(size int) *IntBuilder[T]
MinLen 设置字段的最小长度。
Params:
- size: 字段的最小长度。
func (*IntBuilder[T]) Name ¶
func (i *IntBuilder[T]) Name(name string) *IntBuilder[T]
Name 用于设置字段在数据库中的名称。
如果不设置,会默认采用`snake_case`的方式将字段名转换为数据库字段名,比如示例中的ID字段会被转换为`i_d`。
Params:
- name: 字段在数据库中的名称。
func (*IntBuilder[T]) Primary ¶
func (i *IntBuilder[T]) Primary(index int) *IntBuilder[T]
Primary设置字段为主键。
Params:
- index: 主键的索引,从1开始,对于多个主键,需要设置不同大小的索引。
func (*IntBuilder[T]) Required ¶
func (i *IntBuilder[T]) Required() *IntBuilder[T]
Required 是否非空,默认可以为null,如果调用[Required],则字段为非空字段。
func (*IntBuilder[T]) Sequence ¶
func (i *IntBuilder[T]) Sequence(s entity.Sequence) *IntBuilder[T]
Sequence 设置字段的序列。 如果序列不存在,则会自动创建序列。 优先级高于[Default]。
Params:
- s: 序列。
func (*IntBuilder[T]) Unique ¶ added in v0.9.15
func (i *IntBuilder[T]) Unique(index int) *IntBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。
type IntStorage ¶
type IntStorage[T any] struct { BaseStorage[T] }
type Scanner ¶
type Scanner interface {
// Scan assigns a value from a database driver.
//
// The src value will be of one of the following types:
//
// int64
// float64
// bool
// []bytetaurus_go/entity/field/field.go
// string
// time.Time
// nil - for NULL values
//
// An error should be returned if the value cannot be stored
// without loss of information.
//
// Reference types such as []byte are only valid until the next call to Scan
// and should not be retained. Their underlying memory is owned by the driver.
// If retention is necessary, copy their values before the next call to Scan.
Scan(src any) error
}
Scanner is an interface used by Scan.
type StringStorage ¶
type StringStorage[T any] struct { BaseStorage[T] }
StringStorage[T] 字符串类型的字段存储。
type TextBuilder ¶
type TextBuilder[T any] struct { BaseBuilder[T] }
TextBuilder 文本类型的字段构造器。
func (*TextBuilder[T]) AttrType ¶
func (s *TextBuilder[T]) AttrType(dbType dialect.DbDriver) string
AttrType 获取字段的数据库中的类型名,如果返回空字符串,会出现错误。
Params:
- dbType: 数据库类型。
Returns:
- 字段的数据库中的类型名。
func (*TextBuilder[T]) Comment ¶
func (s *TextBuilder[T]) Comment(comment string) *TextBuilder[T]
Comment 设置字段的注释。
Params:
- comment: 字段的注释。
func (*TextBuilder[T]) Default ¶
func (s *TextBuilder[T]) Default(value string) *TextBuilder[T]
Default 设置字段的默认值。 如果设置了默认值,则在插入数据时,如果没有设置字段的值,则会使用默认值。
Params:
- value: 字段的默认值。
func (*TextBuilder[T]) MinLen ¶
func (s *TextBuilder[T]) MinLen(i int) *TextBuilder[T]
MinLen 设置字段的最小长度。
Params:
- size: 字段的最小长度。
func (*TextBuilder[T]) Name ¶
func (s *TextBuilder[T]) Name(name string) *TextBuilder[T]
Name 用于设置字段在数据库中的名称。
如果不设置,会默认采用`snake_case`的方式将字段名转换为数据库字段名。
Params:
- name: 字段在数据库中的名称。
func (*TextBuilder[T]) Primary ¶
func (s *TextBuilder[T]) Primary(index int) *TextBuilder[T]
Primary设置字段为主键。
Params:
- index: 主键的索引,从1开始,对于多个主键,需要设置不同大小的索引。
func (*TextBuilder[T]) Required ¶
func (s *TextBuilder[T]) Required() *TextBuilder[T]
Required 是否非空,默认可以为null,如果调用[Required],则字段为非空字段。
func (*TextBuilder[T]) Unique ¶ added in v0.9.15
func (s *TextBuilder[T]) Unique(index int) *TextBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。
type TimestampStorage ¶
type TimestampStorage[T any] struct { BaseStorage[T] }
TimestampStorage 时间戳类型的字段存储。
func (*TimestampStorage[T]) SqlParam ¶
func (i *TimestampStorage[T]) SqlParam(dbType dialect.DbDriver) (entity.FieldValue, error)
SqlParam 用于sql中获取字段参数并赋值。如 INSERT INTO "blog" ( "desc") VALUES ($1),给$1传递具体的值。
type Timestamptz ¶
type Timestamptz struct {
TimestamptzBuilder[time.Time]
TimestampStorage[time.Time]
}
Timestamp 时间戳类型的字段。
type TimestamptzA1 ¶
type TimestamptzA1 struct {
TimestamptzBuilder[[]time.Time]
TimestampStorage[[]time.Time]
}
type TimestamptzA2 ¶
type TimestamptzA2 struct {
TimestamptzBuilder[[][]time.Time]
TimestampStorage[[][]time.Time]
}
type TimestamptzA3 ¶
type TimestamptzA3 struct {
TimestamptzBuilder[[][][]time.Time]
TimestampStorage[[][][]time.Time]
}
type TimestamptzA4 ¶
type TimestamptzA4 struct {
TimestamptzBuilder[[][][][]time.Time]
TimestampStorage[[][][][]time.Time]
}
type TimestamptzA5 ¶
type TimestamptzA5 struct {
TimestamptzBuilder[[][][][][]time.Time]
TimestampStorage[[][][][][]time.Time]
}
type TimestamptzBuilder ¶
type TimestamptzBuilder[T any] struct { BaseBuilder[T] // contains filtered or unexported fields }
TimestamptzBuilder 时间戳类型的字段构建器。
func (*TimestamptzBuilder[T]) AttrType ¶
func (t *TimestamptzBuilder[T]) AttrType(dbType dialect.DbDriver) string
AttrType 获取字段的数据库中的类型名,如果返回空字符串,会出现错误。
Params:
- dbType: 数据库类型。
Returns:
- 字段的数据库中的类型名。
func (*TimestamptzBuilder[T]) Comment ¶
func (t *TimestamptzBuilder[T]) Comment(comment string) *TimestamptzBuilder[T]
Comment 设置字段的注释。
Params:
- comment: 字段的注释。
func (*TimestamptzBuilder[T]) Default ¶
func (t *TimestamptzBuilder[T]) Default(value string) *TimestamptzBuilder[T]
Default 设置字段的默认值。 如果设置了默认值,则在插入数据时,如果没有设置字段的值,则会使用默认值。
Params:
- value: 字段的默认值。
func (*TimestamptzBuilder[T]) Init ¶
func (t *TimestamptzBuilder[T]) Init(desc *entity.Descriptor) error
Init 初始化字段的描述信息,在代码生成阶段初始化时调用。
Params:
- desc: 字段的描述信息。
func (*TimestamptzBuilder[T]) Locked ¶
func (t *TimestamptzBuilder[T]) Locked() *TimestamptzBuilder[T]
Locked 设置字段是否为只读。
func (*TimestamptzBuilder[T]) MinLen ¶
func (t *TimestamptzBuilder[T]) MinLen(size int) *TimestamptzBuilder[T]
MinLen 设置字段的最小长度。
Params:
- size: 字段的最小长度。
func (*TimestamptzBuilder[T]) Name ¶
func (t *TimestamptzBuilder[T]) Name(name string) *TimestamptzBuilder[T]
Name 用于设置字段在数据库中的名称。
如果不设置,会默认采用`snake_case`的方式将字段名转换为数据库字段名,比如示例中的ID字段会被转换为`i_d`。
Params:
- name: 字段在数据库中的名称。
func (*TimestamptzBuilder[T]) Precision ¶
func (t *TimestamptzBuilder[T]) Precision(precision int) *TimestamptzBuilder[T]
Precision 设置时间精度。
func (*TimestamptzBuilder[T]) Primary ¶
func (t *TimestamptzBuilder[T]) Primary(index int) *TimestamptzBuilder[T]
Primary设置字段为主键。
Params:
- index: 主键的索引,从1开始,对于多个主键,需要设置不同大小的索引。
func (*TimestamptzBuilder[T]) Required ¶
func (t *TimestamptzBuilder[T]) Required() *TimestamptzBuilder[T]
Required 是否非空,默认可以为null,如果调用[Required],则字段为非空字段。
func (*TimestamptzBuilder[T]) Unique ¶ added in v0.9.15
func (t *TimestamptzBuilder[T]) Unique(index int) *TimestamptzBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。
type UUIDA1 ¶
type UUIDA1 struct {
UUIDBuilder[[]string]
StringStorage[[]string]
}
type UUIDBuilder ¶
type UUIDBuilder[T any] struct { BaseBuilder[T] }
UUIDBuilder UUID类型的字段构造器。
func (*UUIDBuilder[T]) AttrType ¶
func (u *UUIDBuilder[T]) AttrType(dbType dialect.DbDriver) string
AttrType 获取字段的数据库中的类型名,如果返回空字符串,会出现错误。
Params:
- dbType: 数据库类型。
Returns:
- 字段的数据库中的类型名。
func (*UUIDBuilder[T]) Comment ¶
func (u *UUIDBuilder[T]) Comment(comment string) *UUIDBuilder[T]
Comment 设置字段的注释。
Params:
- comment: 字段的注释。
func (*UUIDBuilder[T]) Default ¶
func (u *UUIDBuilder[T]) Default(value *string) *UUIDBuilder[T]
Default 设置字段的默认值。 如果设置了默认值,则在插入数据时,如果没有设置字段的值,则会使用默认值。 如果为空,则会使用"uuid-ossp"扩展的uuid_generate_v4()函数生成。
Params:
- value: 字段的默认值。
func (*UUIDBuilder[T]) Name ¶
func (u *UUIDBuilder[T]) Name(name string) *UUIDBuilder[T]
Name 用于设置字段在数据库中的名称。
如果不设置,会默认采用`snake_case`的方式将字段名转换为数据库字段名,比如示例中的ID字段会被转换为`i_d`。
Params:
- name: 字段在数据库中的名称。
func (*UUIDBuilder[T]) Primary ¶
func (u *UUIDBuilder[T]) Primary(index int) *UUIDBuilder[T]
Primary设置字段为主键。
Params:
- index: 主键的索引,从1开始,对于多个主键,需要设置不同大小的索引。
func (*UUIDBuilder[T]) Required ¶
func (u *UUIDBuilder[T]) Required() *UUIDBuilder[T]
Required 是否非空,默认可以为null,如果调用[Required],则字段为非空字段。
func (*UUIDBuilder[T]) Unique ¶ added in v0.9.15
func (u *UUIDBuilder[T]) Unique(index int) *UUIDBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。
type Varchar ¶
type Varchar struct {
VarcharBuilder[string]
StringStorage[string]
}
Varchar 字符串类型的字段。
type VarcharA1 ¶
type VarcharA1 struct {
VarcharBuilder[[]string]
StringStorage[[]string]
}
type VarcharA2 ¶
type VarcharA2 struct {
VarcharBuilder[[][]string]
StringStorage[[][]string]
}
type VarcharA3 ¶
type VarcharA3 struct {
VarcharBuilder[[][][]string]
StringStorage[[][][]string]
}
type VarcharA4 ¶
type VarcharA4 struct {
VarcharBuilder[[][][][]string]
StringStorage[[][][][]string]
}
type VarcharA5 ¶
type VarcharA5 struct {
VarcharBuilder[[][][][][]string]
StringStorage[[][][][][]string]
}
type VarcharBuilder ¶
type VarcharBuilder[T any] struct { BaseBuilder[T] }
VarcharBuilder 字符串类型的字段构造器。
func (*VarcharBuilder[T]) AttrType ¶
func (s *VarcharBuilder[T]) AttrType(dbType dialect.DbDriver) string
AttrType 获取字段的数据库中的类型名,如果返回空字符串,会出现错误。
Params:
- dbType: 数据库类型。
Returns:
- 字段的数据库中的类型名。
func (*VarcharBuilder[T]) Comment ¶
func (s *VarcharBuilder[T]) Comment(comment string) *VarcharBuilder[T]
Comment 设置字段的注释。
Params:
- comment: 字段的注释。
func (*VarcharBuilder[T]) Default ¶
func (s *VarcharBuilder[T]) Default(value string) *VarcharBuilder[T]
Default 设置字段的默认值。 如果设置了默认值,则在插入数据时,如果没有设置字段的值,则会使用默认值。
Params:
- value: 字段的默认值。
func (*VarcharBuilder[T]) Locked ¶
func (s *VarcharBuilder[T]) Locked() *VarcharBuilder[T]
Locked 设置字段为只读字段。
func (*VarcharBuilder[T]) MaxLen ¶
func (s *VarcharBuilder[T]) MaxLen(i int64) *VarcharBuilder[T]
MaxLen 设置字段的最大长度。
Params:
- i: 字段的最大长度。
func (*VarcharBuilder[T]) MinLen ¶
func (s *VarcharBuilder[T]) MinLen(i int) *VarcharBuilder[T]
MinLen 设置字段的最小长度。
Params:
- size: 字段的最小长度。
func (*VarcharBuilder[T]) Name ¶
func (s *VarcharBuilder[T]) Name(name string) *VarcharBuilder[T]
Name 用于设置字段在数据库中的名称。
如果不设置,会默认采用`snake_case`的方式将字段名转换为数据库字段名,比如示例中的ID字段会被转换为`i_d`。
Params:
- name: 字段在数据库中的名称。
func (*VarcharBuilder[T]) Primary ¶
func (s *VarcharBuilder[T]) Primary(index int) *VarcharBuilder[T]
Primary设置字段为主键。
Params:
- index: 主键的索引,从1开始,对于多个主键,需要设置不同大小的索引。
func (*VarcharBuilder[T]) Required ¶
func (s *VarcharBuilder[T]) Required() *VarcharBuilder[T]
Required 是否非空,默认可以为null,如果调用[Required],则字段为非空字段。
func (*VarcharBuilder[T]) Unique ¶ added in v0.9.15
func (s *VarcharBuilder[T]) Unique(index int) *VarcharBuilder[T]
Unique 设置字段为唯一字段或参与联合唯一约束。 相同的序号表示这些字段组成联合唯一约束。