Versions in this module Expand all Collapse all v1 v1.1.0 Mar 23, 2025 Changes in this version type DaoBuilder + NewReceiver func() T + Receive func(T) []any + type DaoExecStmt struct + Cache bool + Query string + func (s *DaoExecStmt) ToStmt() *ExecStmt + type DaoQueryOneStmt struct + Cache bool + Query string + func (s *DaoQueryOneStmt[T]) ToStmt(newReceiver func() T, receive func(T) []any) *QueryOneStmt[T] + type DaoQueryPageStmt struct + CountStmt *DaoQueryValStmt[int] + QueryStmt *DaoQueryStmt[T] + func (s *DaoQueryPageStmt[T]) ToStmt(newReceiver func() T, receive func(T) []any) *QueryPageStmt[T] + type DaoQueryStmt struct + Cache bool + Query string + func (s *DaoQueryStmt[T]) ToStmt(newReceiver func() T, receive func(T) []any) *QueryStmt[T] + type DaoQueryValStmt struct + Cache bool + Query string + func (s *DaoQueryValStmt[T]) ToStmt() *QueryValStmt[T] v1.0.1 Mar 19, 2025 Changes in this version + var ErrNotFound = errors.New("gosql: entity not found") + var ErrVersionMismatch = errors.New("gosql: version mismatch - entity was modified") + var RO = &sql.TxOptions + var RW = &sql.TxOptions + var TxKey = txKey + func Exec(ctx context.Context, tx *sql.Tx, stmt *sql.Stmt, args ...any) error + func ExecWithTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions, ...) error + func IsNil[T comparable](v T) bool + func Nil[T any]() T + func QueryOne[T any](ctx context.Context, tx *sql.Tx, stmt *sql.Stmt, newReceiver func() T, ...) (T, error) + func QueryVal[T any](ctx context.Context, tx *sql.Tx, stmt *sql.Stmt, args ...any) (T, error) + func QueryWithTx[T any](ctx context.Context, db *sql.DB, opts *sql.TxOptions, ...) (T, error) + func Query[T any](ctx context.Context, tx *sql.Tx, stmt *sql.Stmt, newReceiver func() T, ...) ([]T, error) + func ToSliceOfAny[T any](slice ...T) []any + type BaseStmt struct + Cache bool + Query string + func (stmt *BaseStmt) Close(ctx context.Context) error + type Dao interface + Close func(ctx context.Context) error + Delete func(ctx context.Context, entities ...T) error + DeleteByIds func(ctx context.Context, ids ...uuid.UUID) error + DeleteByIdsCascade func(ctx context.Context, ids ...uuid.UUID) error + DeleteCascade func(ctx context.Context, entities ...T) error + FindById func(ctx context.Context, id uuid.UUID) (T, error) + FindOneByStmt func(ctx context.Context, stmt *QueryOneStmt[T], args ...any) (T, error) + ListAll func(ctx context.Context) ([]T, error) + ListByStmt func(ctx context.Context, stmt *QueryStmt[T], args ...any) ([]T, error) + ListPage func(ctx context.Context, paging Paging) (Page[T], error) + ListPageByStmt func(ctx context.Context, stmt *QueryPageStmt[T], paging Paging, args ...any) (Page[T], error) + Save func(ctx context.Context, entities ...T) error + type DaoBuilder struct + DB *sql.DB + DeleteByIdStmt *ExecStmt + DeleteChildren func(ctx context.Context, tx *sql.Tx, e T) error + GetByIdStmt *QueryOneStmt[T] + InsertArgs func(T) []any + InsertStmt *ExecStmt + ListAllPageStmt *QueryPageStmt[T] + ListAllStmt *QueryStmt[T] + LoadChildren func(ctx context.Context, tx *sql.Tx, e T) error + SaveChildren func(ctx context.Context, tx *sql.Tx, e T) error + UpdateArgs func(T) []any + UpdateStmt *ExecStmt + func (b DaoBuilder[T]) Build(ctx context.Context) (Dao[T], error) + type Entity interface + Equals func(another any) bool + GetID func() uuid.UUID + GetVersion func() uuid.UUID + SetID func(uuid.UUID) + SetVersion func(uuid.UUID) + type ExecStmt struct + func (stmt *ExecStmt) Exec(ctx context.Context, tx *sql.Tx, args ...any) error + type GenericEntity struct + ID uuid.UUID + Version uuid.UUID + func (e *GenericEntity) GetID() uuid.UUID + func (e *GenericEntity) GetVersion() uuid.UUID + func (e *GenericEntity) SetID(id uuid.UUID) + func (e *GenericEntity) SetVersion(version uuid.UUID) + type Page struct + Items []T + TotalPages int + func QueryPage[T any](ctx context.Context, tx *sql.Tx, countStmt, stmt *sql.Stmt, paging Paging, ...) (Page[T], error) + type Paging struct + PageNum int + PageSize int + func (p *Paging) Normalize() + func (p Paging) GetLimit() int + func (p Paging) GetOffset() int + func (p Paging) GetTotalPages(totalRows int) int + type QueryOneStmt struct + NewReceiver func() T + Receive func(T) []any + func (stmt *QueryOneStmt[T]) Query(ctx context.Context, tx *sql.Tx, args ...any) (T, error) + type QueryPageStmt struct + CountStmt *QueryValStmt[int] + QueryStmt *QueryStmt[T] + func (stmt *QueryPageStmt[T]) Close(ctx context.Context) error + func (stmt *QueryPageStmt[T]) QueryPage(ctx context.Context, tx *sql.Tx, paging Paging, args ...any) (Page[T], error) + type QueryStmt struct + NewReceiver func() T + Receive func(T) []any + func (stmt *QueryStmt[T]) Query(ctx context.Context, tx *sql.Tx, args ...any) ([]T, error) + type QueryValStmt struct + func (stmt *QueryValStmt[T]) Query(ctx context.Context, tx *sql.Tx, args ...any) (T, error)