Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRecordNotFound = errors.New("record not found")
Functions ¶
This section is empty.
Types ¶
type CRUD ¶
type CRUD[T any, I comparable] interface { InitSchema(sql string) error InitSchemaContext(ctx context.Context, sql string) error // TODO: add paging result info GetAll(opts ...PagingOpt) ([]*T, error) GetAllContext(ctx context.Context, opts ...PagingOpt) ([]*T, error) GetAllValues(opts ...PagingOpt) ([]T, error) GetAllValuesContext(ctx context.Context, opts ...PagingOpt) ([]T, error) GetByID(id I) (*T, error) GetByIDContext(ctx context.Context, id I) (*T, error) GetValueByID(id I) (T, error) GetValueByIDContext(ctx context.Context, id I) (T, error) GetByIDs(ids []I) ([]*T, error) GetByIDsContext(ctx context.Context, ids []I) ([]*T, error) GetValuesByIDs(ids []I) ([]T, error) GetValuesByIDsContext(ctx context.Context, ids []I) ([]T, error) Create(e *T) error CreateContext(ctx context.Context, e *T) error DeleteAll() error DeleteAllContext(ctx context.Context) error Delete(id I) error DeleteContext(ctx context.Context, id I) error Update(id I, e *T) error UpdateContext(ctx context.Context, id I, e *T) error Count() (int64, error) CountContext(ctx context.Context) (int64, error) }
type PagingOpt ¶
type PagingOpt func(*pagingParams)
func WithOffset ¶
func WithOrderColumn ¶
type SQLCredo ¶
type SQLCredo[T any, I comparable] interface { SQLExecutor CRUD[T, I] WithDebugFunc(newDebugFunc DebugFunc) SQLCredo[T, I] GetDebugFunc() DebugFunc }
func NewSQLCredo ¶
type SQLExecutor ¶
type SQLExecutor interface { SelectOne(dest any, query string, args ...any) error SelectOneContext(ctx context.Context, dest any, query string, args ...any) error SelectMany(dest any, query string, args ...any) error SelectManyContext(ctx context.Context, dest any, query string, args ...any) error Exec(query string, args ...any) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) Begin() (*sql.Tx, error) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) }
Click to show internal directories.
Click to hide internal directories.