sqlite

package module
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GenId  func(context.Context) string
	GenUid func(context.Context) string
)

Functions

func IsErrDuplicated

func IsErrDuplicated(err error) bool

func IsErrNoRows

func IsErrNoRows(err error) bool

Types

type Config

type Config struct {
	DSN           string        `json:"sqlite.dsn"            yaml:"sqlite.dsn"`
	SlowThreshold time.Duration `json:"sqlite.slow_threshold" yaml:"sqlite.slow_threshold"`
}

type DeletedAt

type DeletedAt = gormSD.DeletedAt

DeletedAt `gorm:"uniqueIndex:udx_account_deleted_at" json:"deletedAt,omitempty"`

type GormDB

type GormDB = gorm.DB

func DB

func DB() *GormDB

type ListParams

type ListParams struct {
	Pagination *Pagination `json:"pagination"`
	Sort       []string    `json:"sort,omitempty"`
}

func (*ListParams) GetPagination

func (ps *ListParams) GetPagination() *Pagination

func (*ListParams) Order

func (ps *ListParams) Order() (ss []string)

type ListResult

type ListResult[T any] struct {
	Pagination *Pagination `json:"pagination"`
	Records    []T         `json:"records"`
}

func QueryList

func QueryList[T any](tx *GormDB, ps *ListParams) (_ *ListResult[T], err error)

type Meta

type Meta struct {
	Id        string    `gorm:"type:varchar(36);primaryKey" json:"id"`
	CreatedAt time.Time `gorm:"autoCreateTime:milli" json:"createdAt"`
	CreatedBy string    `gorm:"type:varchar(36)"     json:"createdBy"`
	UpdatedAt time.Time `gorm:"autoUpdateTime:milli" json:"updatedAt,omitempty"`
	UpdatedBy string    `gorm:"type:varchar(36)"     json:"updatedBy,omitempty"`
}

func (*Meta) BeforeCreate

func (t *Meta) BeforeCreate(tx *gorm.DB) error

func (*Meta) BeforeDelete

func (t *Meta) BeforeDelete(tx *gorm.DB) error

func (*Meta) BeforeUpdate

func (t *Meta) BeforeUpdate(tx *gorm.DB) error

type Pagination

type Pagination struct {
	Page     int `json:"current"`
	PageSize int `json:"pageSize"`

	TotalSize int `json:"total"`
	TotalPage int `json:"totalPage"`
}

func (*Pagination) Limit

func (p *Pagination) Limit() int

func (*Pagination) Offset

func (p *Pagination) Offset() int

func (*Pagination) Total

func (p *Pagination) Total(size int64) *Pagination

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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