Documentation
¶
Index ¶
- Variables
- func GetColumnName(err error) string
- func GetConstraintName(err error) string
- func IsConstraintError(err error) bool
- func IsRetryable(err error) bool
- type Action
- type ArrayColumn
- func (c ArrayColumn[T]) Append(value T) Action
- func (c ArrayColumn[T]) Concat(values []T) Action
- func (c ArrayColumn[T]) ContainedBy(values []T) Condition
- func (c ArrayColumn[T]) Contains(value T) Condition
- func (c ArrayColumn[T]) IsEmpty() Condition
- func (c ArrayColumn[T]) IsNotEmpty() Condition
- func (c ArrayColumn[T]) Length() NumericColumn[int]
- func (c ArrayColumn[T]) Overlaps(values []T) Condition
- func (c ArrayColumn[T]) Prepend(value T) Action
- func (c ArrayColumn[T]) Remove(value T) Action
- type AuthorizeFunc
- type BelongsTo
- type BoolColumn
- type Column
- func (c Column[T]) Asc() string
- func (c Column[T]) Desc() string
- func (c Column[T]) Eq(value T) Condition
- func (c Column[T]) In(values ...T) Condition
- func (c Column[T]) IsNotNull() Condition
- func (c Column[T]) IsNull() Condition
- func (c Column[T]) NotEq(value T) Condition
- func (c Column[T]) NotIn(values ...T) Condition
- func (c Column[T]) Set(value T) Action
- func (c Column[T]) SetDefault() Action
- func (c Column[T]) SetNull() Action
- func (c Column[T]) String() string
- type ColumnChange
- type ColumnMetadata
- type Comparable
- type ComparableColumn
- type Condition
- type Config
- type DBExecutor
- type DBWrapper
- type Error
- type ForeignKeyMetadata
- type HasMany
- type HasManyThrough
- type HasOne
- type JSONBColumn
- func (c JSONBColumn) ContainedBy(value interface{}) Condition
- func (c JSONBColumn) Contains(value interface{}) Condition
- func (c JSONBColumn) HasAllKeys(keys []string) Condition
- func (c JSONBColumn) HasAnyKey(keys []string) Condition
- func (c JSONBColumn) HasKey(key string) Condition
- func (c JSONBColumn) Merge(jsonValue interface{}) Action
- func (c JSONBColumn) Path(path string) JSONBColumn
- func (c JSONBColumn) PathText(path string) StringColumn
- func (c JSONBColumn) RemovePath(path string) Action
- func (c JSONBColumn) SetPath(path string, value interface{}) Action
- type JSONData
- type JoinType
- type MiddlewareContext
- type MigrationResult
- type ModelMetadata
- type Numeric
- type NumericColumn
- type OperationType
- type Query
- func (q *Query[T]) Count() (int64, error)
- func (q *Query[T]) Delete() (int64, error)
- func (q *Query[T]) ExecuteRaw(query string, args ...interface{}) ([]T, error)
- func (q *Query[T]) Exists() (bool, error)
- func (q *Query[T]) Find() ([]T, error)
- func (q *Query[T]) First() (*T, error)
- func (q *Query[T]) FullJoin(table, condition string) *Query[T]
- func (q *Query[T]) Include(relationships ...string) *Query[T]
- func (q *Query[T]) IncludeWhere(relationship string, conditions ...Condition) *Query[T]
- func (q *Query[T]) InnerJoin(table, condition string) *Query[T]
- func (q *Query[T]) Join(joinType JoinType, table, condition string) *Query[T]
- func (q *Query[T]) JoinRelationship(relationshipName string, joinType JoinType) *Query[T]
- func (q *Query[T]) LeftJoin(table, condition string) *Query[T]
- func (q *Query[T]) Limit(limit uint64) *Query[T]
- func (q *Query[T]) Offset(offset uint64) *Query[T]
- func (q *Query[T]) OrderBy(expressions ...string) *Query[T]
- func (q *Query[T]) RawJoin(joinClause string, args ...interface{}) *Query[T]
- func (q *Query[T]) RightJoin(table, condition string) *Query[T]
- func (q *Query[T]) Update(actions ...Action) (int64, error)
- func (q *Query[T]) Where(condition Condition) *Query[T]
- func (q *Query[T]) WithTx(tx *sqlx.Tx) *Query[T]
- type QueryLogger
- type QueryMiddleware
- type QueryMiddlewareFunc
- type RelationshipMetadata
- type Repository
- func (r *Repository[T]) AddMiddleware(middleware QueryMiddleware)
- func (r *Repository[T]) Authorize(fn AuthorizeFunc[T]) *Repository[T]
- func (r *Repository[T]) Columns() []string
- func (r *Repository[T]) Create(ctx context.Context, record *T) (*T, error)
- func (r *Repository[T]) CreateMany(ctx context.Context, records []T) error
- func (r *Repository[T]) Delete(ctx context.Context, id interface{}) (*T, error)
- func (r *Repository[T]) DeleteRecord(ctx context.Context, record *T) (*T, error)
- func (r *Repository[T]) FindByID(ctx context.Context, id interface{}) (*T, error)
- func (r *Repository[T]) GetTransactionManager() (*TransactionManager, error)
- func (r *Repository[T]) IsTransaction() bool
- func (r *Repository[T]) PrimaryKeys() []string
- func (r *Repository[T]) Query(ctx context.Context) *Query[T]
- func (r *Repository[T]) TableName() string
- func (r *Repository[T]) Update(ctx context.Context, record *T) (*T, error)
- func (r *Repository[T]) UpdateFields(ctx context.Context, id interface{}, updates map[string]interface{}) (*T, error)
- func (r *Repository[T]) Upsert(ctx context.Context, record *T, opts UpsertOptions) error
- func (r *Repository[T]) UpsertMany(ctx context.Context, records []T, opts UpsertOptions) error
- func (r *Repository[T]) WithRelationships(ctx context.Context) *Query[T]
- func (r *Repository[T]) WithinTransaction(ctx context.Context, fn func(*sqlx.Tx) error) error
- type SimpleQueryLogger
- type Storm
- func (s *Storm) AutoMigrate(ctx context.Context, config Config) (MigrationResult, error)
- func (s *Storm) AutoMigrateDestructive(ctx context.Context, config Config) (MigrationResult, error)
- func (s *Storm) AutoMigrateDryRun(ctx context.Context, config Config) (MigrationResult, error)
- func (s *Storm) GetDB() *sqlx.DB
- func (s *Storm) GetExecutor() DBExecutor
- func (s *Storm) GetLogger() QueryLogger
- func (s *Storm) WithTransaction(ctx context.Context, fn func(*Storm) error) error
- func (s *Storm) WithTransactionOptions(ctx context.Context, opts *TransactionOptions, fn func(*Storm) error) error
- type StringArray
- type StringColumn
- func (c StringColumn) Concat(suffix string) Action
- func (c StringColumn) Contains(substring string) Condition
- func (c StringColumn) EndsWith(suffix string) Condition
- func (c StringColumn) FullTextSearch(query string) Condition
- func (c StringColumn) FullTextSearchLang(language, query string) Condition
- func (c StringColumn) ILike(pattern string) Condition
- func (c StringColumn) Like(pattern string) Condition
- func (c StringColumn) Lower() Action
- func (c StringColumn) Prepend(prefix string) Action
- func (c StringColumn) Regexp(pattern string) Condition
- func (c StringColumn) StartsWith(prefix string) Condition
- func (c StringColumn) Upper() Action
- type Table
- type TimeColumn
- func (c TimeColumn) After(t time.Time) Condition
- func (c TimeColumn) Before(t time.Time) Condition
- func (c TimeColumn) LastNDays(days int) Condition
- func (c TimeColumn) SetCurrentTimestamp() Action
- func (c TimeColumn) SetNow() Action
- func (c TimeColumn) Since(t time.Time) Condition
- func (c TimeColumn) ThisMonth() Condition
- func (c TimeColumn) ThisWeek() Condition
- func (c TimeColumn) Today() Condition
- func (c TimeColumn) Until(t time.Time) Condition
- type TransactionManager
- type TransactionOptions
- type UpsertOptions
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("record not found") ErrInvalidStruct = errors.New("invalid struct type") ErrNoPrimaryKey = errors.New("no primary key defined") ErrDuplicateKey = errors.New("duplicate key violation") ErrForeignKey = errors.New("foreign key violation") ErrCheckConstraint = errors.New("check constraint violation") ErrNotNull = errors.New("not null constraint violation") ErrConnectionFailed = errors.New("database connection failed") ErrTimeout = errors.New("operation timeout") ErrCanceled = errors.New("operation canceled") )
Common errors
Functions ¶
func GetColumnName ¶
func GetConstraintName ¶
func IsConstraintError ¶
func IsRetryable ¶
Types ¶
type Action ¶ added in v0.0.39
type Action struct {
// contains filtered or unexported fields
}
Action represents a type-safe database update operation
func (Action) Expression ¶ added in v0.0.39
type ArrayColumn ¶
ArrayColumn provides PostgreSQL array-specific operations
func (ArrayColumn[T]) Append ¶ added in v0.0.39
func (c ArrayColumn[T]) Append(value T) Action
ArrayColumn action methods
func (ArrayColumn[T]) Concat ¶ added in v0.0.39
func (c ArrayColumn[T]) Concat(values []T) Action
func (ArrayColumn[T]) ContainedBy ¶
func (c ArrayColumn[T]) ContainedBy(values []T) Condition
func (ArrayColumn[T]) Contains ¶
func (c ArrayColumn[T]) Contains(value T) Condition
func (ArrayColumn[T]) IsEmpty ¶
func (c ArrayColumn[T]) IsEmpty() Condition
func (ArrayColumn[T]) IsNotEmpty ¶
func (c ArrayColumn[T]) IsNotEmpty() Condition
func (ArrayColumn[T]) Length ¶
func (c ArrayColumn[T]) Length() NumericColumn[int]
func (ArrayColumn[T]) Overlaps ¶
func (c ArrayColumn[T]) Overlaps(values []T) Condition
func (ArrayColumn[T]) Prepend ¶ added in v0.0.39
func (c ArrayColumn[T]) Prepend(value T) Action
func (ArrayColumn[T]) Remove ¶ added in v0.0.39
func (c ArrayColumn[T]) Remove(value T) Action
type AuthorizeFunc ¶ added in v0.0.31
AuthorizeFunc defines a callback function for applying authorization to queries It receives the request context and query object, and returns a modified query
type BelongsTo ¶
type BelongsTo[TSource any, TTarget any, PK comparable] struct { // contains filtered or unexported fields }
Relationship types with full type safety
type BoolColumn ¶
BoolColumn provides boolean-specific operations
func (BoolColumn) IsFalse ¶
func (c BoolColumn) IsFalse() Condition
func (BoolColumn) IsTrue ¶
func (c BoolColumn) IsTrue() Condition
type Column ¶
Column represents a type-safe database column reference
func (Column[T]) SetDefault ¶ added in v0.0.39
type ColumnChange ¶ added in v0.0.50
type ColumnMetadata ¶
type ColumnMetadata struct {
FieldName string // Go struct field name
DBName string // Database column name
DBType string // Database type
GoType string // Go type
IsPrimaryKey bool // Is this a primary key?
IsAutoGenerated bool // Is this auto-generated (serial, default:now(), etc)?
IsNullable bool // Can this be NULL?
IsUnique bool // Has unique constraint?
IsPointer bool // Is this a pointer field in Go struct?
Default string // Default value
Tags map[string]string // All dbdef tags
Constraints []string // Check constraints
ForeignKey *ForeignKeyMetadata // Foreign key info if applicable
// Generated accessor functions for zero-reflection field access
GetValue func(model interface{}) interface{} // Extract field value (handles pointer dereferencing)
IsNil func(model interface{}) bool // Check if pointer field is nil (only for pointer fields)
}
ColumnMetadata contains metadata for a single column
type Comparable ¶
type Comparable interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
~float32 | ~float64 |
~string |
time.Time
}
Comparable types that support comparison operators
type ComparableColumn ¶
type ComparableColumn[T Comparable] struct { Column[T] }
ComparableColumn provides comparison operations for comparable types
func (ComparableColumn[T]) Between ¶
func (c ComparableColumn[T]) Between(min, max T) Condition
func (ComparableColumn[T]) Gt ¶
func (c ComparableColumn[T]) Gt(value T) Condition
func (ComparableColumn[T]) Gte ¶
func (c ComparableColumn[T]) Gte(value T) Condition
func (ComparableColumn[T]) Lt ¶
func (c ComparableColumn[T]) Lt(value T) Condition
func (ComparableColumn[T]) Lte ¶
func (c ComparableColumn[T]) Lte(value T) Condition
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition wraps squirrel conditions for type safety
type DBExecutor ¶
type DBExecutor interface {
// Query execution methods from sqlx.ExtContext
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
// Additional sqlx methods
QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
// Named query support
NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
BindNamed(query string, arg interface{}) (string, []interface{}, error)
// Prepared statements
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
// Rebind for driver-specific placeholders
Rebind(query string) string
// DriverName returns the driverName passed to the Open function for this DB.
DriverName() string
}
DBExecutor represents an interface that can execute database operations. It can be satisfied by both *sqlx.DB and *sqlx.Tx, allowing repositories to work with either regular connections or transactions.
type DBWrapper ¶
type DBWrapper interface {
DBExecutor
BeginTxx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
Close() error
Ping() error
PingContext(ctx context.Context) error
Stats() sql.DBStats
}
DBWrapper provides additional database-specific operations that are only available on *sqlx.DB (not on transactions)
type Error ¶
type Error struct {
Op string // Operation that failed
Table string // Table involved
Err error // Underlying error
Query string // SQL query (if applicable)
Args []interface{} // Query arguments (if applicable)
Constraint string // Constraint name (if applicable)
Column string // Column name (if applicable)
Retryable bool // Whether the operation can be retried
}
Error provides detailed error information
type ForeignKeyMetadata ¶
type ForeignKeyMetadata struct {
ReferencedTable string
ReferencedColumn string
OnDelete string
OnUpdate string
}
ForeignKeyMetadata contains foreign key information
type HasMany ¶
type HasMany[TSource any, TTarget any, PK comparable] struct { // contains filtered or unexported fields }
type HasManyThrough ¶
type HasManyThrough[TSource any, TTarget any, TJoin any, PK comparable] struct { // contains filtered or unexported fields }
type HasOne ¶
type HasOne[TSource any, TTarget any, PK comparable] struct { // contains filtered or unexported fields }
type JSONBColumn ¶
type JSONBColumn struct {
Column[interface{}]
}
JSONBColumn provides PostgreSQL JSONB-specific operations
func (JSONBColumn) ContainedBy ¶
func (c JSONBColumn) ContainedBy(value interface{}) Condition
func (JSONBColumn) Contains ¶
func (c JSONBColumn) Contains(value interface{}) Condition
func (JSONBColumn) HasAllKeys ¶
func (c JSONBColumn) HasAllKeys(keys []string) Condition
func (JSONBColumn) HasAnyKey ¶
func (c JSONBColumn) HasAnyKey(keys []string) Condition
func (JSONBColumn) HasKey ¶
func (c JSONBColumn) HasKey(key string) Condition
func (JSONBColumn) Merge ¶ added in v0.0.39
func (c JSONBColumn) Merge(jsonValue interface{}) Action
func (JSONBColumn) Path ¶
func (c JSONBColumn) Path(path string) JSONBColumn
func (JSONBColumn) PathText ¶
func (c JSONBColumn) PathText(path string) StringColumn
func (JSONBColumn) RemovePath ¶ added in v0.0.39
func (c JSONBColumn) RemovePath(path string) Action
func (JSONBColumn) SetPath ¶ added in v0.0.39
func (c JSONBColumn) SetPath(path string, value interface{}) Action
JSONBColumn action methods
type JSONData ¶
func NewJSONData ¶ added in v0.0.29
func NewNullJSONData ¶ added in v0.0.29
func NewNullJSONData() JSONData
type MiddlewareContext ¶
type MiddlewareContext struct {
Operation OperationType
TableName string
Record interface{}
Records interface{}
QueryBuilder interface{} // squirrel.SelectBuilder, squirrel.InsertBuilder, etc.
Query string
Args []interface{}
Error error
StartTime time.Time
Duration time.Duration
Context context.Context
Metadata map[string]interface{}
}
MiddlewareContext contains information passed to middleware
type MigrationResult ¶ added in v0.0.50
type MigrationResult struct {
TablesCreated []string
TablesDropped []string
ColumnsAdded []ColumnChange
ColumnsDropped []ColumnChange
IndexesCreated []string
IndexesDropped []string
SQL []string
Duration time.Duration
}
type ModelMetadata ¶
type ModelMetadata struct {
// Basic table information
TableName string
StructName string
// Column mappings
Columns map[string]*ColumnMetadata // key is Go field name
ColumnMap map[string]string // Go field -> DB column
ReverseMap map[string]string // DB column -> Go field
// Primary keys only - other column lists are determined dynamically
PrimaryKeys []string // DB column names
// Relationships
Relationships map[string]*RelationshipMetadata
}
ModelMetadata contains all the metadata needed for ORM operations This will be generated at compile time instead of parsed at runtime
type Numeric ¶
type Numeric interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
~float32 | ~float64
}
Numeric types for mathematical operations
type NumericColumn ¶
type NumericColumn[T Numeric] struct { ComparableColumn[T] }
NumericColumn provides numeric-specific operations
func (NumericColumn[T]) Decrement ¶ added in v0.0.39
func (c NumericColumn[T]) Decrement(amount T) Action
func (NumericColumn[T]) Increment ¶ added in v0.0.39
func (c NumericColumn[T]) Increment(amount T) Action
NumericColumn action methods
func (NumericColumn[T]) Multiply ¶ added in v0.0.39
func (c NumericColumn[T]) Multiply(factor T) Action
type OperationType ¶
type OperationType string
OperationType represents different types of database operations
const ( OpCreate OperationType = "create" OpCreateMany OperationType = "create_many" OpUpdate OperationType = "update" OpUpdateMany OperationType = "update_many" OpDelete OperationType = "delete" OpUpsert OperationType = "upsert" OpUpsertMany OperationType = "upsert_many" OpBulkUpdate OperationType = "bulk_update" OpFind OperationType = "find" OpQuery OperationType = "query" )
type Query ¶
type Query[T any] struct { // contains filtered or unexported fields }
Query provides a fluent interface for building database queries with all features integrated
func (*Query[T]) ExecuteRaw ¶
func (*Query[T]) IncludeWhere ¶
func (*Query[T]) JoinRelationship ¶
type QueryLogger ¶ added in v0.0.43
type QueryLogger interface {
LogQuery(query string, args []interface{}, duration time.Duration, err error)
}
QueryLogger defines the interface for logging SQL queries
type QueryMiddleware ¶
type QueryMiddleware func(next QueryMiddlewareFunc) QueryMiddlewareFunc
QueryMiddleware represents middleware that can see and modify query builders
type QueryMiddlewareFunc ¶
type QueryMiddlewareFunc func(ctx *MiddlewareContext) error
QueryMiddlewareFunc represents middleware that can modify queries
type RelationshipMetadata ¶
type RelationshipMetadata struct {
Name string
Type string // belongs_to, has_one, has_many, has_many_through
Target string // Target model name
TargetTable string // Target table name (optional, uses Target if empty)
ForeignKey string // Foreign key field
TargetKey string // Target key field (for belongs_to)
SourceKey string // Source key field (for has_one/has_many)
Through string // Through model (for has_many_through)
ThroughFK string // Through foreign key
ThroughTK string // Through target key
// Generated function - zero reflection, atomic operation
// Scans database results directly into the model's relationship field
ScanToModel func(ctx context.Context, exec DBExecutor, query string, args []interface{}, model interface{}) error
}
RelationshipMetadata contains relationship information
type Repository ¶
type Repository[T any] struct { // contains filtered or unexported fields }
Repository provides type-safe database operations for a specific model type
func NewRepository ¶
func NewRepository[T any](db *sqlx.DB, metadata *ModelMetadata) (*Repository[T], error)
func NewRepositoryWithExecutor ¶
func NewRepositoryWithExecutor[T any](executor DBExecutor, metadata *ModelMetadata) (*Repository[T], error)
func NewRepositoryWithTx ¶
func NewRepositoryWithTx[T any](tx *sqlx.Tx, metadata *ModelMetadata) (*Repository[T], error)
func (*Repository[T]) AddMiddleware ¶
func (r *Repository[T]) AddMiddleware(middleware QueryMiddleware)
func (*Repository[T]) Authorize ¶ added in v0.0.31
func (r *Repository[T]) Authorize(fn AuthorizeFunc[T]) *Repository[T]
Authorize returns a new Repository instance with an additional authorization function Multiple authorization functions can be chained and will be applied in order
func (*Repository[T]) Columns ¶
func (r *Repository[T]) Columns() []string
func (*Repository[T]) Create ¶
func (r *Repository[T]) Create(ctx context.Context, record *T) (*T, error)
func (*Repository[T]) CreateMany ¶
func (r *Repository[T]) CreateMany(ctx context.Context, records []T) error
func (*Repository[T]) Delete ¶
func (r *Repository[T]) Delete(ctx context.Context, id interface{}) (*T, error)
func (*Repository[T]) DeleteRecord ¶
func (r *Repository[T]) DeleteRecord(ctx context.Context, record *T) (*T, error)
func (*Repository[T]) FindByID ¶
func (r *Repository[T]) FindByID(ctx context.Context, id interface{}) (*T, error)
func (*Repository[T]) GetTransactionManager ¶
func (r *Repository[T]) GetTransactionManager() (*TransactionManager, error)
func (*Repository[T]) IsTransaction ¶
func (r *Repository[T]) IsTransaction() bool
func (*Repository[T]) PrimaryKeys ¶
func (r *Repository[T]) PrimaryKeys() []string
func (*Repository[T]) TableName ¶
func (r *Repository[T]) TableName() string
func (*Repository[T]) Update ¶
func (r *Repository[T]) Update(ctx context.Context, record *T) (*T, error)
func (*Repository[T]) UpdateFields ¶ added in v0.0.27
func (r *Repository[T]) UpdateFields(ctx context.Context, id interface{}, updates map[string]interface{}) (*T, error)
UpdateFields updates specific fields of a single record by primary key
func (*Repository[T]) Upsert ¶
func (r *Repository[T]) Upsert(ctx context.Context, record *T, opts UpsertOptions) error
func (*Repository[T]) UpsertMany ¶
func (r *Repository[T]) UpsertMany(ctx context.Context, records []T, opts UpsertOptions) error
func (*Repository[T]) WithRelationships ¶
func (r *Repository[T]) WithRelationships(ctx context.Context) *Query[T]
func (*Repository[T]) WithinTransaction ¶
type SimpleQueryLogger ¶ added in v0.0.43
type SimpleQueryLogger struct{}
SimpleQueryLogger is a basic implementation of QueryLogger that logs to stdout
type Storm ¶
type Storm struct {
// contains filtered or unexported fields
}
Storm is the main entry point for all ORM operations It holds all repositories and manages database connections
func (*Storm) AutoMigrate ¶ added in v0.0.50
func (*Storm) AutoMigrateDestructive ¶ added in v0.0.50
func (*Storm) AutoMigrateDryRun ¶ added in v0.0.50
func (*Storm) GetExecutor ¶
func (s *Storm) GetExecutor() DBExecutor
func (*Storm) GetLogger ¶ added in v0.0.43
func (s *Storm) GetLogger() QueryLogger
GetLogger returns the query logger if set
func (*Storm) WithTransaction ¶
func (*Storm) WithTransactionOptions ¶
type StringArray ¶ added in v0.0.29
type StringArray []string
StringArray handles PostgreSQL text[] arrays
func (*StringArray) Scan ¶ added in v0.0.29
func (sa *StringArray) Scan(value interface{}) error
Scan implements the sql.Scanner interface for StringArray
type StringColumn ¶
StringColumn provides string-specific operations
func (StringColumn) Concat ¶ added in v0.0.39
func (c StringColumn) Concat(suffix string) Action
StringColumn action methods
func (StringColumn) Contains ¶
func (c StringColumn) Contains(substring string) Condition
func (StringColumn) EndsWith ¶
func (c StringColumn) EndsWith(suffix string) Condition
func (StringColumn) FullTextSearch ¶ added in v0.0.19
func (c StringColumn) FullTextSearch(query string) Condition
func (StringColumn) FullTextSearchLang ¶ added in v0.0.19
func (c StringColumn) FullTextSearchLang(language, query string) Condition
func (StringColumn) ILike ¶
func (c StringColumn) ILike(pattern string) Condition
func (StringColumn) Like ¶
func (c StringColumn) Like(pattern string) Condition
func (StringColumn) Lower ¶ added in v0.0.39
func (c StringColumn) Lower() Action
func (StringColumn) Prepend ¶ added in v0.0.39
func (c StringColumn) Prepend(prefix string) Action
func (StringColumn) Regexp ¶
func (c StringColumn) Regexp(pattern string) Condition
func (StringColumn) StartsWith ¶
func (c StringColumn) StartsWith(prefix string) Condition
func (StringColumn) Upper ¶ added in v0.0.39
func (c StringColumn) Upper() Action
type Table ¶
type Table struct {
Name string `json:"name"`
PrimaryKeys []string `json:"primary_keys"`
Schema string `json:"schema,omitempty"`
}
Table provides table-level operations and metadata
func (Table) GetPrimaryKeyColumns ¶
func (Table) HasPrimaryKey ¶
func (Table) IsCompositePrimaryKey ¶
type TimeColumn ¶
type TimeColumn struct {
ComparableColumn[time.Time]
}
TimeColumn provides time-specific operations
func (TimeColumn) LastNDays ¶
func (c TimeColumn) LastNDays(days int) Condition
func (TimeColumn) SetCurrentTimestamp ¶ added in v0.0.39
func (c TimeColumn) SetCurrentTimestamp() Action
func (TimeColumn) SetNow ¶ added in v0.0.39
func (c TimeColumn) SetNow() Action
TimeColumn action methods
func (TimeColumn) ThisMonth ¶
func (c TimeColumn) ThisMonth() Condition
func (TimeColumn) ThisWeek ¶
func (c TimeColumn) ThisWeek() Condition
func (TimeColumn) Today ¶
func (c TimeColumn) Today() Condition
type TransactionManager ¶
type TransactionManager struct {
// contains filtered or unexported fields
}
TransactionManager provides utilities for managing transactions across repositories
func NewTransactionManager ¶
func NewTransactionManager(db *sqlx.DB) *TransactionManager
func (*TransactionManager) WithTransaction ¶
func (*TransactionManager) WithTransactionOptions ¶
func (tm *TransactionManager) WithTransactionOptions(ctx context.Context, opts *TransactionOptions, fn func(*sqlx.Tx) error) error
type TransactionOptions ¶
type TransactionOptions struct {
Isolation sql.IsolationLevel
ReadOnly bool
}
TransactionOptions configures transaction behavior
func DefaultTransactionOptions ¶
func DefaultTransactionOptions() *TransactionOptions
func (*TransactionOptions) ToTxOptions ¶
func (o *TransactionOptions) ToTxOptions() *sql.TxOptions
type UpsertOptions ¶
type UpsertOptions struct {
ConflictColumns []string // Columns that define conflicts (ON CONFLICT)
UpdateColumns []string // Columns to update on conflict (if empty, updates all non-conflict columns)
UpdateExpr map[string]string // Custom update expressions (column -> expression)
}
UpsertOptions configures upsert behavior
type ValidationError ¶
ValidationError represents validation errors
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors represents multiple validation errors
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string