Documentation
¶
Index ¶
- func NormalizeOffset(offset int) int
- func NormalizePage(page int) int
- func NormalizePagination(page int, perPage int) (int, int)
- func NormalizePerPage(perPage int) int
- func ScanRowsWithScanner[T any](rows pgx.Rows, scanner func(pgx.Row) (T, error)) ([]T, error)
- func ToPgArray[T any](slice []T) goqu.Expression
- func ToPostgresArray(value interface{}) []interface{}
- type Filter
- type Model
- type Oper
- type PaginationInfo
- type Paginator
- type Querier
- type QueryOption
- func WithFilter(rules ...Rule) QueryOption
- func WithLimit(limit int) QueryOption
- func WithLimitOffset(limit int, offset int) QueryOption
- func WithOffset(offset int) QueryOption
- func WithPagination(page int, perPage int) QueryOption
- func WithSort(field string, sort string) QueryOption
- func WithSortAsc(field string) QueryOption
- func WithSortDesc(field string) QueryOption
- type RecordBuilder
- type Repository
- func (r *Repository[T]) Count(ctx context.Context, opts ...QueryOption) (int64, error)
- func (r *Repository[T]) Delete(ctx context.Context, id uuid.UUID) error
- func (r *Repository[T]) DeleteBatch(ctx context.Context, ids []uuid.UUID) error
- func (r *Repository[T]) FindByID(ctx context.Context, id uuid.UUID) (T, error)
- func (r *Repository[T]) Insert(ctx context.Context, entity T) (T, error)
- func (r *Repository[T]) InsertBatch(ctx context.Context, entities []T) error
- func (r *Repository[T]) List(ctx context.Context, opts ...QueryOption) ([]T, error)
- func (r *Repository[T]) One(ctx context.Context, opts ...QueryOption) (T, error)
- func (r *Repository[T]) Paginate(ctx context.Context, page int, perPage int, opts ...QueryOption) (*Paginator[T], error)
- func (r *Repository[T]) Update(ctx context.Context, entity T) (T, error)
- type RowsScanner
- type Rule
- type Scanner
- type Sort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeOffset ¶
func NormalizePage ¶
func NormalizePerPage ¶
func ScanRowsWithScanner ¶
func ToPgArray ¶
func ToPgArray[T any](slice []T) goqu.Expression
func ToPostgresArray ¶
func ToPostgresArray(value interface{}) []interface{}
Types ¶
type Oper ¶
type Oper string
const ( OpEqual Oper = "=" OpNotEqual Oper = "!=" OpGreaterThan Oper = ">" OpGreaterThanOrEqual Oper = ">=" OpLessThan Oper = "<" OpLessThanOrEqual Oper = "<=" OpLike Oper = "LIKE" OpILike Oper = "ILIKE" OpIn Oper = "IN" OpNotIn Oper = "NOT IN" OpIsNull Oper = "IS NULL" OpIsNotNull Oper = "IS NOT NULL" OpContains Oper = "CONTAINS" // array (@>) OpContainedBy Oper = "CONTAINED_BY" // array (<@) OpOverlaps Oper = "OVERLAPS" // array (&&) OpJsonContains Oper = "JSON_CONTAINS" // JSONB (@>) OpJsonExists Oper = "JSON_EXISTS" // JSONB (?) )
type PaginationInfo ¶
type Paginator ¶
type Paginator[T any] struct { Items []T `json:"items"` Total int64 `json:"total"` Page int `json:"page"` PerPage int `json:"perPage"` TotalPages int `json:"totalPages"` HasNext bool `json:"next"` HasPrev bool `json:"prev"` }
func (*Paginator[T]) GetHasNext ¶
func (*Paginator[T]) GetHasPrev ¶
func (*Paginator[T]) GetPerPage ¶
func (*Paginator[T]) GetTotalPages ¶
type QueryOption ¶
type QueryOption func(*queryConfig)
func WithFilter ¶
func WithFilter(rules ...Rule) QueryOption
func WithLimit ¶
func WithLimit(limit int) QueryOption
func WithLimitOffset ¶
func WithLimitOffset(limit int, offset int) QueryOption
func WithOffset ¶
func WithOffset(offset int) QueryOption
func WithPagination ¶
func WithPagination(page int, perPage int) QueryOption
func WithSort ¶
func WithSort(field string, sort string) QueryOption
func WithSortAsc ¶
func WithSortAsc(field string) QueryOption
func WithSortDesc ¶
func WithSortDesc(field string) QueryOption
type RecordBuilder ¶
type Repository ¶
type Repository[T Model] struct { // contains filtered or unexported fields }
func NewRepository ¶
func NewRepository[T Model]( pool *pgxpool.Pool, table string, scanner Scanner[T], rowsScanner RowsScanner[T], recordBuilder RecordBuilder[T], ) *Repository[T]
func (*Repository[T]) Count ¶
func (r *Repository[T]) Count(ctx context.Context, opts ...QueryOption) (int64, error)
func (*Repository[T]) DeleteBatch ¶
func (*Repository[T]) Insert ¶
func (r *Repository[T]) Insert(ctx context.Context, entity T) (T, error)
func (*Repository[T]) InsertBatch ¶
func (r *Repository[T]) InsertBatch(ctx context.Context, entities []T) error
func (*Repository[T]) List ¶
func (r *Repository[T]) List(ctx context.Context, opts ...QueryOption) ([]T, error)
func (*Repository[T]) One ¶
func (r *Repository[T]) One(ctx context.Context, opts ...QueryOption) (T, error)
func (*Repository[T]) Paginate ¶
func (r *Repository[T]) Paginate( ctx context.Context, page int, perPage int, opts ...QueryOption, ) (*Paginator[T], error)
Click to show internal directories.
Click to hide internal directories.