Documentation
¶
Index ¶
- Variables
- func EncodeCursor(cursor PageCursor) string
- func MySQLOpen(url string) (*sql.DB, error)
- func NewPool(ctx context.Context, cfg PoolConfig) (*pgxpool.Pool, error)
- func SetSlowThreshold(d time.Duration)
- func TursoOpen(url string) (*sql.DB, error)
- type ColumnValue
- type Constraint
- type FieldInfo
- type MySQLTable
- func (t *MySQLTable[T]) AutoInit(ctx context.Context) error
- func (t *MySQLTable[T]) Close() error
- func (t *MySQLTable[T]) Count(ctx context.Context) (int64, error)
- func (t *MySQLTable[T]) CountScoped(ctx context.Context, tenantField, tenantID string) (int64, error)
- func (t *MySQLTable[T]) Create(ctx context.Context, entity *T) error
- func (t *MySQLTable[T]) CreateScoped(ctx context.Context, entity *T, tenantField string, tenantID string) error
- func (t *MySQLTable[T]) DB() *sql.DB
- func (t *MySQLTable[T]) Delete(ctx context.Context, id any) error
- func (t *MySQLTable[T]) DeleteScoped(ctx context.Context, id any, tenantField string, tenantID string) error
- func (t *MySQLTable[T]) Get(ctx context.Context, id any) (*T, error)
- func (t *MySQLTable[T]) GetScoped(ctx context.Context, id any, tenantField string, tenantID string) (*T, error)
- func (t *MySQLTable[T]) List(ctx context.Context) ([]T, error)
- func (t *MySQLTable[T]) ListPaginated(ctx context.Context, limit, offset int) ([]T, error)
- func (t *MySQLTable[T]) ListScoped(ctx context.Context, tenantField string, tenantID string) ([]T, error)
- func (t *MySQLTable[T]) ListScopedPaginated(ctx context.Context, tenantField, tenantID string, limit, offset int) ([]T, error)
- func (t *MySQLTable[T]) QueryKeyset(ctx context.Context, cursor string, size int, orderBy string, ...) ([]T, string, error)
- func (t *MySQLTable[T]) Update(ctx context.Context, id any, patch map[string]any) (*T, error)
- func (t *MySQLTable[T]) UpdateScoped(ctx context.Context, id any, patch map[string]any, tenantField string, ...) (*T, error)
- type PageCursor
- type PaginatedResponse
- type PoolConfig
- type PreparedTable
- func (pt *PreparedTable[T]) Count(ctx context.Context) (int64, error)
- func (pt *PreparedTable[T]) Delete(ctx context.Context, id any) error
- func (pt *PreparedTable[T]) Exists(ctx context.Context, column string, value any) (bool, error)
- func (pt *PreparedTable[T]) Get(ctx context.Context, id any) (*T, error)
- func (pt *PreparedTable[T]) List(ctx context.Context) ([]T, error)
- type Table
- func (t *Table[T]) AutoInit(ctx context.Context) error
- func (t *Table[T]) BatchInsert(ctx context.Context, entities []T) error
- func (t *Table[T]) Count(ctx context.Context, where ...ColumnValue) (int64, error)
- func (t *Table[T]) Create(ctx context.Context, entity *T) error
- func (t *Table[T]) CreateScoped(ctx context.Context, entity *T, tenantField string, tenantID string) error
- func (t *Table[T]) Delete(ctx context.Context, id any) error
- func (t *Table[T]) DeleteScoped(ctx context.Context, id any, tenantField string, tenantID string) error
- func (t *Table[T]) ExecRaw(ctx context.Context, sql string, args ...any) (int64, error)
- func (t *Table[T]) Exists(ctx context.Context, column string, value any) (bool, error)
- func (t *Table[T]) FindBy(ctx context.Context, column string, value any) (*T, error)
- func (t *Table[T]) Get(ctx context.Context, id any) (*T, error)
- func (t *Table[T]) GetScoped(ctx context.Context, id any, tenantField string, tenantID string) (*T, error)
- func (t *Table[T]) Increment(ctx context.Context, id any, column string, amount int64) error
- func (t *Table[T]) List(ctx context.Context) ([]T, error)
- func (t *Table[T]) ListScoped(ctx context.Context, tenantField string, tenantID string) ([]T, error)
- func (t *Table[T]) PrimaryKey() string
- func (t *Table[T]) QueryKeyset(ctx context.Context, cursor string, size int, orderBy string, ...) ([]T, string, error)
- func (t *Table[T]) QueryPaginated(ctx context.Context, page, size int, orderBy string) ([]T, int64, error)
- func (t *Table[T]) QueryWhere(ctx context.Context, where map[string]any, orderBy string, limit, offset int) ([]T, error)
- func (t *Table[T]) ResolveColumn(jsonKey string) string
- func (t *Table[T]) ResolvePatch(patch map[string]any) map[string]any
- func (t *Table[T]) TableInfo() *TableInfo
- func (t *Table[T]) Transaction(ctx context.Context, fn func(tx pgx.Tx) error) error
- func (t *Table[T]) Update(ctx context.Context, id any, patch map[string]any) (*T, error)
- func (t *Table[T]) UpdateScoped(ctx context.Context, id any, patch map[string]any, tenantField string, ...) (*T, error)
- func (t *Table[T]) Upsert(ctx context.Context, entity *T, conflictColumn string) error
- type TableConstraints
- type TableInfo
- type TursoTable
- func (t *TursoTable[T]) AutoInit(ctx context.Context) error
- func (t *TursoTable[T]) Close() error
- func (t *TursoTable[T]) Count(ctx context.Context) (int64, error)
- func (t *TursoTable[T]) CountScoped(ctx context.Context, tenantField, tenantID string) (int64, error)
- func (t *TursoTable[T]) Create(ctx context.Context, entity *T) error
- func (t *TursoTable[T]) CreateScoped(ctx context.Context, entity *T, tenantField string, tenantID string) error
- func (t *TursoTable[T]) DB() *sql.DB
- func (t *TursoTable[T]) Delete(ctx context.Context, id any) error
- func (t *TursoTable[T]) DeleteScoped(ctx context.Context, id any, tenantField string, tenantID string) error
- func (t *TursoTable[T]) Get(ctx context.Context, id any) (*T, error)
- func (t *TursoTable[T]) GetScoped(ctx context.Context, id any, tenantField string, tenantID string) (*T, error)
- func (t *TursoTable[T]) List(ctx context.Context) ([]T, error)
- func (t *TursoTable[T]) ListPaginated(ctx context.Context, limit, offset int) ([]T, error)
- func (t *TursoTable[T]) ListScoped(ctx context.Context, tenantField string, tenantID string) ([]T, error)
- func (t *TursoTable[T]) ListScopedPaginated(ctx context.Context, tenantField, tenantID string, limit, offset int) ([]T, error)
- func (t *TursoTable[T]) QueryKeyset(ctx context.Context, cursor string, size int, orderBy string, ...) ([]T, string, error)
- func (t *TursoTable[T]) Update(ctx context.Context, id any, patch map[string]any) (*T, error)
- func (t *TursoTable[T]) UpdateScoped(ctx context.Context, id any, patch map[string]any, tenantField string, ...) (*T, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func EncodeCursor ¶ added in v0.11.0
func EncodeCursor(cursor PageCursor) string
func SetSlowThreshold ¶ added in v0.11.0
Types ¶
type ColumnValue ¶
type ColumnValue struct {
// contains filtered or unexported fields
}
func Col ¶
func Col(col string, val any) ColumnValue
type Constraint ¶ added in v0.13.0
type Constraint struct {
Type string // "UNIQUE", "INDEX", "CHECK"
Columns []string // column names in order
Name string // optional constraint name
}
Constraint represents a table-level constraint such as UNIQUE(a,b).
type MySQLTable ¶
type MySQLTable[T any] struct { // contains filtered or unexported fields }
func NewMySQLTable ¶
func NewMySQLTableFromURL ¶
func NewMySQLTableFromURL[T any](url string, tableName string) (*MySQLTable[T], error)
func (*MySQLTable[T]) Close ¶
func (t *MySQLTable[T]) Close() error
func (*MySQLTable[T]) Count ¶ added in v0.14.0
func (t *MySQLTable[T]) Count(ctx context.Context) (int64, error)
func (*MySQLTable[T]) CountScoped ¶ added in v0.14.0
func (*MySQLTable[T]) CreateScoped ¶ added in v0.10.0
func (*MySQLTable[T]) DB ¶
func (t *MySQLTable[T]) DB() *sql.DB
func (*MySQLTable[T]) DeleteScoped ¶ added in v0.10.0
func (*MySQLTable[T]) ListPaginated ¶ added in v0.14.0
func (t *MySQLTable[T]) ListPaginated(ctx context.Context, limit, offset int) ([]T, error)
func (*MySQLTable[T]) ListScoped ¶ added in v0.10.0
func (*MySQLTable[T]) ListScopedPaginated ¶ added in v0.14.0
func (*MySQLTable[T]) QueryKeyset ¶ added in v0.6.0
type PageCursor ¶ added in v0.11.0
func ParseCursor ¶ added in v0.11.0
func ParseCursor(encoded string) (PageCursor, error)
type PaginatedResponse ¶ added in v0.11.0
type PaginatedResponse[T any] struct { Items []T `json:"items"` NextCursor string `json:"next_cursor,omitempty"` HasMore bool `json:"has_more"` }
func NewPaginatedResponse ¶ added in v0.11.0
func NewPaginatedResponse[T any](items []T, nextCursor string) PaginatedResponse[T]
type PoolConfig ¶
type PoolConfig struct {
URL string
MaxConns int32
MinConns int32
MaxConnLifetime time.Duration
MaxConnIdleTime time.Duration
HealthCheckPeriod time.Duration
StatementTimeout time.Duration
ApplicationName string
}
func DefaultPoolConfig ¶
func DefaultPoolConfig() PoolConfig
type PreparedTable ¶ added in v0.14.0
func NewPreparedTable ¶ added in v0.14.0
func (*PreparedTable[T]) Count ¶ added in v0.14.0
func (pt *PreparedTable[T]) Count(ctx context.Context) (int64, error)
func (*PreparedTable[T]) Delete ¶ added in v0.14.0
func (pt *PreparedTable[T]) Delete(ctx context.Context, id any) error
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
func (*Table[T]) BatchInsert ¶
func (*Table[T]) CreateScoped ¶ added in v0.10.0
func (*Table[T]) DeleteScoped ¶ added in v0.10.0
func (*Table[T]) ListScoped ¶ added in v0.10.0
func (*Table[T]) PrimaryKey ¶
func (*Table[T]) QueryKeyset ¶ added in v0.6.0
func (*Table[T]) QueryPaginated ¶
func (*Table[T]) QueryWhere ¶
func (*Table[T]) ResolveColumn ¶
func (*Table[T]) ResolvePatch ¶
func (*Table[T]) Transaction ¶
func (*Table[T]) UpdateScoped ¶ added in v0.10.0
type TableConstraints ¶ added in v0.13.0
type TableConstraints interface {
Constraints() []Constraint
}
TableConstraints is an optional interface that structs can implement to declare table-level constraints (composite unique, foreign keys, etc.).
type TableInfo ¶
func ParseStruct ¶
type TursoTable ¶
type TursoTable[T any] struct { // contains filtered or unexported fields }
func NewTursoTable ¶
func NewTursoTable[T any](url string, tableName string) (*TursoTable[T], error)
func NewTursoTableFrom ¶
func (*TursoTable[T]) Close ¶
func (t *TursoTable[T]) Close() error
func (*TursoTable[T]) Count ¶ added in v0.14.0
func (t *TursoTable[T]) Count(ctx context.Context) (int64, error)
func (*TursoTable[T]) CountScoped ¶ added in v0.14.0
func (*TursoTable[T]) CreateScoped ¶ added in v0.10.0
func (*TursoTable[T]) DB ¶ added in v0.14.0
func (t *TursoTable[T]) DB() *sql.DB
func (*TursoTable[T]) DeleteScoped ¶ added in v0.10.0
func (*TursoTable[T]) ListPaginated ¶ added in v0.14.0
func (t *TursoTable[T]) ListPaginated(ctx context.Context, limit, offset int) ([]T, error)
func (*TursoTable[T]) ListScoped ¶ added in v0.10.0
func (*TursoTable[T]) ListScopedPaginated ¶ added in v0.14.0
func (*TursoTable[T]) QueryKeyset ¶ added in v0.6.0
Click to show internal directories.
Click to hide internal directories.