datapipe

package module
v0.0.0-...-25ab797 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

README

data pipeline

Documentation

Index

Constants

View Source
const (
	DefaultPageSize = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBSource

type DBSource[T any, K comparable] struct {
	// contains filtered or unexported fields
}

func NewDBDataSource

func NewDBDataSource[T any, K comparable](db *gorm.DB) *DBSource[T, K]

func NewDBDataTableSource

func NewDBDataTableSource[T any, K comparable](db *gorm.DB, table string, pk ...string) *DBSource[T, K]

func (*DBSource[T, K]) Delete

func (ds *DBSource[T, K]) Delete(key K) error

func (*DBSource[T, K]) GetItem

func (ds *DBSource[T, K]) GetItem(key K) (item T, err error)

func (*DBSource[T, K]) GetList

func (ds *DBSource[T, K]) GetList(params Params) DataList[T]

func (*DBSource[T, K]) Pagination

func (ds *DBSource[T, K]) Pagination(tx *gorm.DB, pageIndex int, pageSize int, dest interface{}, countField ...string) (meta PageMeta, err error)

func (*DBSource[T, K]) Store

func (ds *DBSource[T, K]) Store(item *T) error

func (*DBSource[T, K]) Update

func (ds *DBSource[T, K]) Update(key K, item *T) error

type DataList

type DataList[T any] interface {
	GetData() []T
}

type DataSource

type DataSource[T any, K comparable] interface {
	GetList(params Params) DataList[T]
	GetItem(key K) (T, error)
	Store(item *T) error
	Update(key K, item *T) error
	Delete(key K) error
}

type PageMeta

type PageMeta struct {
	Page    int `json:"page"`
	PerPage int `json:"pre_page"`
	Total   int `json:"total"`
}

type PageParam

type PageParam struct {
	Page, PerPage int
}

type PagenationDataList

type PagenationDataList interface {
	GetPageMeta() PageMeta
}

type Params

type Params map[string]interface{}

func (Params) WithPage

func (p Params) WithPage(page, perPage int) Params

func (Params) WithScopes

func (p Params) WithScopes(scopes ...func(db *gorm.DB) *gorm.DB) Params

type Scopes

type Scopes []func(*gorm.DB) *gorm.DB

type SimpleDataList

type SimpleDataList[T any] struct {
	Items []T      `json:"items"`
	Meta  PageMeta `json:"meta"`
}

func NewSimpleDataList

func NewSimpleDataList[T any](items []T) *SimpleDataList[T]

func NewSimpleDataPageList

func NewSimpleDataPageList[T any](items []T, meta PageMeta) *SimpleDataList[T]

func (*SimpleDataList[T]) GetData

func (sd *SimpleDataList[T]) GetData() []T

Jump to

Keyboard shortcuts

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