pgxz

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = false

Functions

func Count

func Count[T IModel](db *PgDb, whereSql string, whereArgs ...any) (int64, error)

func Create

func Create(db *PgDb, col ICol) error

func CreateAndReturn added in v0.0.3

func CreateAndReturn[T IModel](db *PgDb, col ICol) (*T, error)

func Delete added in v0.0.6

func Delete(db *PgDb, col ICol, options ...IOption) (int64, error)

Delete return RowsAffected and error

func GetAll added in v0.0.7

func GetAll[T IModel](db *PgDb, col ICol, options ...IOption) ([]T, error)

func GetOne

func GetOne[T IModel](db *PgDb, col ICol, options ...IOption) (*T, error)

func GroupBy added in v0.0.8

func GroupBy(sql string) *groupOption

func Limit added in v0.0.8

func Limit(v int64) *limitOption

func Offset added in v0.0.8

func Offset(v int64) *offsetOption

func OrderBy added in v0.0.8

func OrderBy(sql string) *orderOption

func Update

func Update(db *PgDb, updates ICol, options ...IOption) (int64, error)

Update return RowsAffected and error

func Where added in v0.0.8

func Where(sql string, args ...any) *whereOption

Types

type Col

type Col struct {
	// contains filtered or unexported fields
}

func (*Col) HasKey added in v0.0.5

func (c *Col) HasKey(key string) bool

func (*Col) Init

func (c *Col) Init(km KyeMap)

func (*Col) IsSet added in v0.0.6

func (c *Col) IsSet(key string) bool

func (*Col) Keys added in v0.0.5

func (c *Col) Keys() []string

func (*Col) Mapping

func (c *Col) Mapping() map[string]any

func (*Col) Set

func (c *Col) Set(fn string, v any)

func (*Col) SetMust added in v0.0.5

func (c *Col) SetMust(fn string, v any)

SetMust When setting the value, the value must not nil

type ICol

type ICol interface {
	TableName() string

	Init(km KyeMap)
	Set(fn string, v any)
	SetMust(fn string, v any)

	Keys() []string
	HasKey(k string) bool
	IsSet(k string) bool
	Mapping() map[string]any
	// contains filtered or unexported methods
}

type IModel

type IModel interface {
	TableName() string
}

type IOption added in v0.0.8

type IOption interface {
	ToSql() string
}

type IPageParams added in v0.0.9

type IPageParams interface {
	GetPageNum() int64
	GetPageSize() int64
}

type KyeMap added in v0.0.5

type KyeMap map[string]struct{}

type OptionGroup added in v0.0.8

type OptionGroup struct {
	// contains filtered or unexported fields
}

type OptionType added in v0.0.8

type OptionType uint8

type PageParams added in v0.0.9

type PageParams struct {
	PageNum  int64 `json:",omitempty"`
	PageSize int64 `json:",omitempty"`
}

func (PageParams) GetPageNum added in v0.0.9

func (p PageParams) GetPageNum() int64

func (PageParams) GetPageSize added in v0.0.9

func (p PageParams) GetPageSize() int64

type PageResult added in v0.0.9

type PageResult[T any] struct {
	Pagination
	List []T
}

func Page added in v0.0.9

func Page[T any](db *PgDb, selectSql, filterSql, orderSql string, pageParams IPageParams) (*PageResult[T], error)

type Pagination added in v0.0.9

type Pagination struct {
	PageNum     int64 // 第几页
	PageSize    int64 // 每页几条
	PageTotal   int64 // 总共几页
	Total       int64 // 总共几条
	IsFirstPage bool  // 是否是第一页
	IsLastPage  bool  // 是否是最后一页
}

func NewPagination added in v0.0.9

func NewPagination(pageParams IPageParams) Pagination

func (*Pagination) Compute added in v0.0.9

func (p *Pagination) Compute(total int64)

func (*Pagination) GetSkipRows added in v0.0.9

func (p *Pagination) GetSkipRows() int64

type PgDb

type PgDb struct {
	*pgxpool.Pool
}

func New

func New(pool *pgxpool.Pool) *PgDb

type UserPageParams added in v0.0.9

type UserPageParams struct {
	DeptId int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL