Documentation ¶
Index ¶
- func ParseConds(conds []any) []any
- func ParseSortParam(s string) [][]string
- func ParseSortValue(s string) (col, dir string)
- func WithPaging(db *gorm.DB, page, perPage int) *gorm.DB
- func WithSorting(db *gorm.DB, sort string, quoteCol func(name string) string) *gorm.DB
- type Intf
- type Repo
- func (d *Repo[T]) Count(ctx context.Context, count *int64, conds ...any) error
- func (d *Repo[T]) Create(ctx context.Context, input *T) error
- func (d *Repo[T]) CreateInBatches(ctx context.Context, input []T, batchSize int) error
- func (d *Repo[T]) Delete(ctx context.Context, conds ...any) error
- func (d *Repo[T]) Existed(ctx context.Context, conds ...any) (bool, error)
- func (d *Repo[T]) List(ctx context.Context, output interface{}, conds ...any) error
- func (r *Repo[T]) QuoteCol(name string) string
- func (d *Repo[T]) Read(ctx context.Context, output *T, conds ...any) error
- func (d *Repo[T]) ReadAllByCondition(ctx context.Context, output interface{}, count *int64, ...) error
- func (d *Repo[T]) ReadByID(ctx context.Context, output *T, id string) error
- func (d *Repo[T]) ReadByUpdate(ctx context.Context, options string, output *T, conds ...any) error
- func (d *Repo[T]) Update(ctx context.Context, updates any, conds ...any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseConds ¶ added in v0.0.4
ParseConds returns standard [sqlString, vars] format for query, powered by gowhere package (with default config)
func ParseSortParam ¶ added in v0.0.4
ParseSortParam returns list of [column, direction] from comma separated sorting param
func ParseSortValue ¶ added in v0.0.4
ParseSortValue returns the column name and direction for sorting value like +column or -column
func WithPaging ¶ added in v0.0.4
WithPaging an util function to set pagination conditions
Types ¶
type Intf ¶ added in v0.0.6
type Intf[T any] interface { Create(ctx context.Context, input *T) error CreateInBatches(ctx context.Context, input []T, batchSize int) error Read(ctx context.Context, output *T, conds ...any) error ReadByID(ctx context.Context, output *T, id string) error ReadByUpdate(ctx context.Context, options string, output *T, conds ...any) error List(ctx context.Context, output interface{}, conds ...any) error Update(ctx context.Context, updates any, conds ...any) error Delete(ctx context.Context, conds ...any) error Count(ctx context.Context, count *int64, conds ...any) error Existed(ctx context.Context, conds ...any) (bool, error) ReadAllByCondition(ctx context.Context, output interface{}, count *int64, lqc *requestutil.ListQueryCondition) error }
Intf represents the common interface for all repositories
type Repo ¶
Repo represents the client for common usages
func (*Repo[T]) CreateInBatches ¶
CreateInBatches creates multiple records in batches
func (*Repo[T]) ReadAllByCondition ¶
func (d *Repo[T]) ReadAllByCondition(ctx context.Context, output interface{}, count *int64, lqc *requestutil.ListQueryCondition) error
ReadAllByCondition retrieves a list of entities based on the provided query conditions.
func (*Repo[T]) ReadByUpdate ¶
ReadByUpdate gets a record and lock it for update
Click to show internal directories.
Click to hide internal directories.