Documentation
¶
Index ¶
- Variables
- func All[T any](ctx context.Context, stmt *Stmt, sizehint int, args ...any) ([]T, error)
- func AllSafe[T any](ctx context.Context, stmt *Stmt, sizehint int, args ...any) ([]T, error)
- func AsModel[T any]()
- func DisableEnsureBackedUp()
- func First[T any](ctx context.Context, stmt *Stmt, args ...any) (*T, error)
- func FirstSafe[T any](ctx context.Context, stmt *Stmt, args ...any) (*T, error)
- func InitAllLazyStmts(ctx context.Context, mapfn func(*LazyStmt) bool) error
- func Logger() *slog.Logger
- func MustDB(ctx context.Context) *sql.DB
- func MustTx(ctx context.Context) *sql.Tx
- func Page[T any](ctx context.Context, stmt *Stmt, rows *sql.Rows, page []T) ([]T, bool, error)
- func PageSafe[T any](ctx context.Context, stmt *Stmt, rows *sql.Rows, page []T) ([]T, bool, error)
- func PeekDB(ctx context.Context) *sql.DB
- func PeekTx(ctx context.Context) *sql.Tx
- func Stream[T any](ctx context.Context, stmt *Stmt, rows *sql.Rows) iter.Seq2[*T, error]
- func Sync(ctx context.Context) error
- func TxScope(ctx context.Context, f func(ctx context.Context) error, opts *sql.TxOptions) error
- func UnwrapSqlNullType(st reflect.Type) (reflect.Type, bool)
- func WithDB(ctx context.Context, db *sql.DB) context.Context
- func WithDialect(ctx context.Context, dialect IDialect) context.Context
- func WithExec(ctx context.Context, exec IExecutor) context.Context
- func WithTx(ctx context.Context, tx *sql.Tx) context.Context
- type Field
- type FieldWithTag
- type IDialect
- type IExecutor
- type LazyStmt
- type LazyStmtGroup
- type MapOperator
- type ModelField
- type ModelInfo
- type ReduceOperator
- type Stmt
- func (s *Stmt) Args(vals ...any) ([]any, error)
- func (s *Stmt) Exec(ctx context.Context, args ...any) (sql.Result, error)
- func (s *Stmt) MustExec(ctx context.Context, args ...any) sql.Result
- func (s *Stmt) MustRows(ctx context.Context, args ...any) *sql.Rows
- func (s *Stmt) Rows(ctx context.Context, args ...any) (*sql.Rows, error)
- type Tag
- type TagOptions
- type TypeInfo
- func (ti *TypeInfo) Field(tagname, name string, iface reflect.Type) (*FieldWithTag, error)
- func (ti *TypeInfo) Fields(tagname string, iface reflect.Type) ([]*FieldWithTag, error)
- func (ti *TypeInfo) MustField(tagname, name string, iface reflect.Type) *FieldWithTag
- func (ti *TypeInfo) MustFields(tagname string, iface reflect.Type) []*FieldWithTag
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ParamsRegexp = regexp.MustCompile(`\$\{(\s*\[a-zA-Z_]+[a-zA-Z_0-9]*\s*)\}`)
)
Functions ¶
func DisableEnsureBackedUp ¶
func DisableEnsureBackedUp()
func InitAllLazyStmts ¶
Types ¶
type FieldWithTag ¶
type IDialect ¶
type IDialect interface {
EnsureTables(ctx context.Context, infos []*ModelInfo) error
ParamPlaceholder(index int) string
}
func MustDialect ¶
func PeekDialect ¶
type IExecutor ¶
type IExecutor interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
func MustExecutor ¶
func PeekExecutor ¶
type LazyStmt ¶
type LazyStmt struct {
*Stmt
// contains filtered or unexported fields
}
func NewLazyStmt ¶
type LazyStmtGroup ¶
type LazyStmtGroup struct {
// contains filtered or unexported fields
}
func NewLazyStmtGroup ¶
func NewLazyStmtGroup() *LazyStmtGroup
func (*LazyStmtGroup) New ¶
func (g *LazyStmtGroup) New(rawsql string) *LazyStmt
type MapOperator ¶
type ModelField ¶
type ModelField struct {
Name string
GoType reflect.Type
Opts TagOptions
}
type ModelInfo ¶
type ModelInfo struct {
GoType reflect.Type
Fields []*ModelField
}
type ReduceOperator ¶
type Tag ¶
type Tag struct {
Name string
Opts TagOptions
}
type TagOptions ¶
func (*TagOptions) HasAny ¶
func (opts *TagOptions) HasAny(keys ...string) bool
type TypeInfo ¶
func GetTypeInfo ¶
func (*TypeInfo) MustField ¶
func (ti *TypeInfo) MustField(tagname, name string, iface reflect.Type) *FieldWithTag
func (*TypeInfo) MustFields ¶
func (ti *TypeInfo) MustFields(tagname string, iface reflect.Type) []*FieldWithTag
Source Files
¶
Click to show internal directories.
Click to hide internal directories.