model

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {
	Aggregate() enum.AggregateType
}

type Attribute

type Attribute struct {
	Table         string
	Name          string
	AggregateType enum.AggregateType
	FunctionType  enum.FunctionType
}

type AttributeMigrate

type AttributeMigrate struct {
	Nullable     bool
	Name         string
	EscapingName string
	DataType     string
	Default      string
}

type Attributer

type Attributer interface {
	Attribute(Body) Attribute
	GetField() any
}

type Body

type Body struct {
	Table string
	Name  string
}

type Config

type Config interface {
	Name() string
	GetDatabaseConfig() *DatabaseConfig
}

type Connection

type Connection interface {
	ExecContext(ctx context.Context, query *Query) error
	QueryRowContext(ctx context.Context, query *Query) Row
	QueryContext(ctx context.Context, query *Query) (Rows, error)
}

type DatabaseConfig

type DatabaseConfig struct {
	Logger           Logger
	IncludeArguments bool          // include all arguments used on query
	QueryThreshold   time.Duration // query threshold to warning on slow queries
	// contains filtered or unexported fields
}

DatabaseConfig Database config used by all GOE drivers

func (DatabaseConfig) ErrorHandler

func (c DatabaseConfig) ErrorHandler(ctx context.Context, err error) error

func (DatabaseConfig) ErrorQueryHandler

func (c DatabaseConfig) ErrorQueryHandler(ctx context.Context, query Query) error

func (DatabaseConfig) InfoHandler

func (c DatabaseConfig) InfoHandler(ctx context.Context, query Query)

func (*DatabaseConfig) Init

func (c *DatabaseConfig) Init(driverName string, errorTranslator func(err error) error)

func (DatabaseConfig) InitCallback

func (c DatabaseConfig) InitCallback() func() error

func (DatabaseConfig) Schemas

func (c DatabaseConfig) Schemas() []string

func (*DatabaseConfig) SetInitCallback

func (c *DatabaseConfig) SetInitCallback(f func() error)

func (*DatabaseConfig) SetSchemas

func (c *DatabaseConfig) SetSchemas(s []string)

type Driver

type Driver interface {
	MigrateContext(context.Context, *Migrator) error
	DropTable(schema, table string) error
	DropColumn(schema, table, column string) error
	RenameColumn(schema, table, oldColumn, newName string) error
	RenameTable(schema, table, newName string) error
	Init() error
	AddLogger(Logger, error) error
	KeywordHandler(string) string
	NewConnection() Connection
	NewTransaction(ctx context.Context, opts *sql.TxOptions) (Transaction, error)
	Stats() sql.DBStats
	Close() error
	ErrorTranslator() func(err error) error
	Config
}

type FunctionType

type FunctionType interface {
	GetType() enum.FunctionType
}

type GroupBy

type GroupBy struct {
	Attribute Attribute
}

type IndexMigrate

type IndexMigrate struct {
	Name         string
	EscapingName string
	Unique       bool
	Func         string
	Attributes   []AttributeMigrate
}

type Join

type Join struct {
	Table          Table
	FirstArgument  JoinArgument
	JoinOperation  enum.JoinType
	SecondArgument JoinArgument
}

type JoinArgument

type JoinArgument struct {
	Table string
	Name  string
}

type Joins

type Joins interface {
	FirstArg() any
	Join() enum.JoinType
	SecondArg() any
}

type Logger

type Logger interface {
	InfoContext(ctx context.Context, msg string, kv ...any)
	WarnContext(ctx context.Context, msg string, kv ...any)
	ErrorContext(ctx context.Context, msg string, kv ...any)
}

type ManyToSomeMigrate

type ManyToSomeMigrate struct {
	TargetTable          string
	TargetColumn         string
	EscapingTargetTable  string
	EscapingTargetColumn string
	TargetSchema         *string
	AttributeMigrate
}

ManyToSomeMigrate M2O/M2M relationship

func (ManyToSomeMigrate) EscapingTargetTableName

func (m ManyToSomeMigrate) EscapingTargetTableName() string

EscapingTargetTableName returns the target table and the schema.

type Migrator

type Migrator struct {
	Tables  map[string]*TableMigrate
	Schemas []string
	Error   error
}

type OneToSomeMigrate

type OneToSomeMigrate struct {
	IsOneToOne           bool
	TargetTable          string
	TargetColumn         string
	EscapingTargetTable  string
	EscapingTargetColumn string
	TargetSchema         *string
	AttributeMigrate
}

OneToSomeMigrate O2M/O2O relationship

func (OneToSomeMigrate) EscapingTargetTableName

func (o OneToSomeMigrate) EscapingTargetTableName() string

EscapingTargetTableName returns the target table and the schema.

type Operation

type Operation struct {
	Type                enum.WhereType
	Arg                 any
	Value               ValueOperation
	Operator            enum.OperatorType
	Attribute           string
	Table               Table
	TableId             int
	Function            enum.FunctionType
	AttributeValue      string
	AttributeValueTable Table
	AttributeTableId    int
	FirstOperation      *Operation
	SecondOperation     *Operation
}

type OrderBy

type OrderBy struct {
	Desc      bool
	Attribute Attribute
}

type PrimaryKeyMigrate

type PrimaryKeyMigrate struct {
	AutoIncrement bool
	AttributeMigrate
}

type Query

type Query struct {
	Type       enum.QueryType
	Attributes []Attribute
	Tables     []Table

	Joins     []Join    // Select
	Limit     int       // Select
	Offset    int       // Select
	OrderBy   []OrderBy // Select
	GroupBy   []GroupBy // Select
	ForUpdate bool      // Select

	WhereOperations []Where // Select, Update and Delete
	WhereIndex      int     // Start of where position arguments $1, $2...
	Arguments       []any

	ReturningID    *Attribute // Insert
	BatchSizeQuery int        // Insert
	SizeArguments  int        // Insert

	RawSql string
	Header QueryHeader
}

type QueryHeader

type QueryHeader struct {
	Err           error
	ModelBuild    time.Duration
	QueryDuration time.Duration
}

type Row

type Row interface {
	Scan(dest ...any) error
}

type Rows

type Rows interface {
	Close() error
	Next() bool
	Row
}

type SavePoint

type SavePoint interface {
	Commit() error
	Rollback() error
}

type Set

type Set struct {
	Attribute any
	Value     any
}

type Table

type Table struct {
	Schema *string
	Name   string
}

func (Table) String

func (t Table) String() string

type TableMigrate

type TableMigrate struct {
	Name         string
	EscapingName string
	Schema       *string
	Migrated     bool
	PrimaryKeys  []PrimaryKeyMigrate
	Indexes      []IndexMigrate
	Attributes   []AttributeMigrate
	ManyToSomes  []ManyToSomeMigrate
	OneToSomes   []OneToSomeMigrate
}

func (TableMigrate) EscapingTableName

func (t TableMigrate) EscapingTableName() string

EscapingTableName returns the table and the schema.

type Transaction

type Transaction interface {
	Connection
	Commit() error
	Rollback() error
	SavePoint() (SavePoint, error)
}

type ValueOperation

type ValueOperation interface {
	GetValue() any
}

type Where

type Where struct {
	Type           enum.WhereType
	Attribute      Attribute
	Operator       enum.OperatorType
	AttributeValue Attribute
	SizeIn         uint
	QueryIn        *Query
}

Jump to

Keyboard shortcuts

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