Documentation
¶
Index ¶
- Variables
- func MySQLOpen(url string) (*sql.DB, error)
- func NewPool(ctx context.Context, cfg PoolConfig) (*pgxpool.Pool, error)
- func TursoOpen(url string) (*sql.DB, error)
- type ColumnValue
- type FieldInfo
- type MySQLTable
- func (t *MySQLTable[T]) AutoInit(ctx context.Context) error
- func (t *MySQLTable[T]) Close() error
- func (t *MySQLTable[T]) Create(ctx context.Context, entity *T) error
- func (t *MySQLTable[T]) DB() *sql.DB
- func (t *MySQLTable[T]) Delete(ctx context.Context, id any) error
- func (t *MySQLTable[T]) Get(ctx context.Context, id any) (*T, error)
- func (t *MySQLTable[T]) List(ctx context.Context) ([]T, error)
- func (t *MySQLTable[T]) Update(ctx context.Context, id any, patch map[string]any) (*T, error)
- type PoolConfig
- 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]) Delete(ctx context.Context, id any) 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]) 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]) PrimaryKey() string
- 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]) Upsert(ctx context.Context, entity *T, conflictColumn string) error
- type TableInfo
- type TursoTable
- func (t *TursoTable[T]) AutoInit(ctx context.Context) error
- func (t *TursoTable[T]) Close() error
- func (t *TursoTable[T]) Create(ctx context.Context, entity *T) error
- func (t *TursoTable[T]) Delete(ctx context.Context, id any) error
- func (t *TursoTable[T]) Get(ctx context.Context, id any) (*T, error)
- func (t *TursoTable[T]) List(ctx context.Context) ([]T, error)
- func (t *TursoTable[T]) Update(ctx context.Context, id any, patch map[string]any) (*T, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type ColumnValue ¶
type ColumnValue struct {
// contains filtered or unexported fields
}
func Col ¶
func Col(col string, val any) ColumnValue
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]) DB ¶
func (t *MySQLTable[T]) DB() *sql.DB
type PoolConfig ¶
type PoolConfig struct {
URL string
MaxConns int32
MinConns int32
MaxConnLifetime time.Duration
MaxConnIdleTime time.Duration
HealthCheckPeriod time.Duration
}
func DefaultPoolConfig ¶
func DefaultPoolConfig() PoolConfig
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
func (*Table[T]) BatchInsert ¶
func (*Table[T]) PrimaryKey ¶
func (*Table[T]) QueryPaginated ¶
func (*Table[T]) QueryWhere ¶
func (*Table[T]) ResolveColumn ¶
func (*Table[T]) ResolvePatch ¶
func (*Table[T]) Transaction ¶
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
Click to show internal directories.
Click to hide internal directories.