Documentation
¶
Index ¶
- type Builder
- type BuilderUse
- type Condition
- type Config
- type Connector
- type Driver
- type DriverField
- type DriverJoin
- type DriverLimit
- type DriverWhere
- type ErrFieldNoFoundByColumn
- type ErrFieldRequired
- type ErrNotFoundError
- type ErrPrimaryFieldNotFound
- type ErrRequiredFieldJoin
- type ErrUnknownFields
- type ErrUnknownOperator
- type FieldDefinition
- type JoinMethod
- type Model
- type ModelDefinition
- type NewPayload
- type NewSubBuilder
- type NewSubBuilderJob
- type Payload
- type PayloadAugmented
- type SqlIn
- type SubBuilder
- type SubBuilderJob
- type UseModelDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder[T Model] interface { Context() context.Context Connector() Connector Get(primaryKey any) (T, error) Delete(primaryKey any) error Create() (err error) Update() error Find() (T, error) FindAll() ([]T, error) SetFields(field ...string) Builder[T] SetWhere(condition Condition) Builder[T] SetLimit(limit int) Builder[T] SetOffset(offset int) Builder[T] SetOrderBy(fields ...string) Builder[T] Count() (total int64, err error) Payload() PayloadAugmented[T] SetModel(model T) Builder[T] Fields() []string Wheres() []Condition }
type BuilderUse ¶
type Config ¶
type Config interface {
Name() string
SetName(name string) Config
Driver() string
SetDriver(driver string) Config
User() string
SetUser(user string) Config
Password() string
SetPassword(password string) Config
Host() string
SetHost(host string) Config
Port() int
SetPort(port int) Config
Database() string
SetDatabase(database string) Config
Locale() string
SetLocale(locale string) Config
}
type DriverField ¶
type DriverField interface {
Index() int
Column() string
Database() string
Table() string
Name() string
IsCustom() bool
SetIndex(index int) DriverField
SetColumn(name string) DriverField
SetTable(name string) DriverField
SetDatabase(name string) DriverField
SetName(name string) DriverField
SetCustom(fn string, args []DriverField) DriverField
Formatted() (string, error)
}
DriverField is the interface that wraps the basic methods of a field.
type DriverJoin ¶
type DriverJoin interface {
Validate() error
Method() string
From() DriverField
To() DriverField
SetMethod(method JoinMethod) DriverJoin
SetFrom(field DriverField) DriverJoin
SetTo(field DriverField) DriverJoin
Formatted() (string, error)
}
type DriverLimit ¶
type DriverLimit interface {
Offset() int
Limit() int
SetOffset(index int) DriverLimit
SetLimit(index int) DriverLimit
Formatted() (string, error)
}
type DriverWhere ¶
type DriverWhere interface {
From() DriverField
Operator() string
To() any
SetFrom(from DriverField) DriverWhere
SetOperator(operator string) DriverWhere
SetTo(to any) DriverWhere
Formatted() (value string, args []any, err error)
}
type ErrFieldNoFoundByColumn ¶
type ErrFieldNoFoundByColumn interface {
error
Column() string
ModelDefinition() ModelDefinition
}
type ErrFieldRequired ¶
type ErrFieldRequired error
type ErrNotFoundError ¶
type ErrNotFoundError error
type ErrPrimaryFieldNotFound ¶
type ErrPrimaryFieldNotFound error
type ErrRequiredFieldJoin ¶
type ErrUnknownFields ¶
type ErrUnknownOperator ¶
type FieldDefinition ¶
type FieldDefinition interface {
// Init allows you to initialise the field with its default value recursively (to avoid `nil`)
Init()
// Name returns the name of the field
Name() string
// Model returns the schema of the field
Model() ModelDefinition
// Tags returns the tags of the field
Tags() map[string]string
FromSchemaTypeList() []string
RecursiveFullName() string
FundamentalName() string
Column() string
ForeignKey() string
Index() int
GetByColumn() (FieldDefinition, error)
GetToColumn() (FieldDefinition, error)
Join() []DriverJoin
Field() DriverField
Value() reflect.Value
Copy() any
Set(value any)
Get() any
HasEmbeddedSchema() bool
EmbeddedSchema() ModelDefinition
IsSlice() bool
FromSlice() bool
IsPrimaryKey() bool
}
FieldDefinition is the interface that describes a field
type JoinMethod ¶
type JoinMethod int
type ModelDefinition ¶
type ModelDefinition interface {
Model
Fields() []FieldDefinition
FieldByName() map[string]FieldDefinition
GetFieldByName(name string) (FieldDefinition, ErrNotFoundError)
GetPrimaryField() (FieldDefinition, ErrPrimaryFieldNotFound)
GetFieldByColumn(column string) (FieldDefinition, ErrFieldNoFoundByColumn)
SetFromField(fromField FieldDefinition) ModelDefinition
FromField() FieldDefinition
SetIndex(index int) ModelDefinition
Index() int
Counter() int
Parse() ModelDefinition
TypeName() string
ModelValue() reflect.Value
ModelOrigin() reflect.Value
Copy() Model
}
type NewPayload ¶
type NewPayload[T Model] func(model ...Model) PayloadAugmented[T]
type NewSubBuilder ¶
type NewSubBuilder[T Model] func() SubBuilder[T]
type NewSubBuilderJob ¶
type NewSubBuilderJob[T Model] func(builder Builder[T], fundamentalName string, model ModelDefinition) SubBuilderJob[T]
type Payload ¶
type Payload interface {
Table() string
Database() string
Index() int
Fields() []DriverField
Join() []DriverJoin
Where() []DriverWhere
Limit() DriverLimit
SetFields([]DriverField) Payload
SetJoins([]DriverJoin) Payload
SetWheres([]DriverWhere) Payload
SetLimit(DriverLimit) Payload
Mapping() ([]any, error)
OnScan([]any) error
}
type PayloadAugmented ¶
type SubBuilder ¶
type SubBuilder[T Model] interface { AddJob(Builder[T], string, ModelDefinition) SubBuilder[T] Execute() error }
type SubBuilderJob ¶
type UseModelDefinition ¶
type UseModelDefinition func(model Model) ModelDefinition
Click to show internal directories.
Click to hide internal directories.