query

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KeyWhere    = "{{.where}}"
	KeyPageSize = "page_size"
	KeyPage     = "page"
)

Variables

View Source
var (
	PageSize = 100 // default page size
)

Functions

func Query added in v0.10.14

func Query[T any](db *gorm.DB, r *RawQuery, data map[string]any) ([]T, error)

Types

type PagingResult added in v0.10.18

type PagingResult[T any] struct {
	Page      int
	PageSize  int
	TotalPage int64
	Total     int64
	Error     error `json:",omitempty"`
	Data      []T   `json:",omitempty"`
}

type RawQuery

type RawQuery struct {
	Connection string // which connection should be used for query.
	Sql        string
	SumRef     string // reference to another RawQuery define, not used yet.
	SumEnabled bool
	Preset     map[string]any
	Params     []string
	Where      map[string]string // key: where condition, value: param key, e.g. "id = ?", "id"
	Orderby    string
	Groupby    string
}

func (*RawQuery) PagingResult added in v0.10.18

func (r *RawQuery) PagingResult(db *gorm.DB, result []map[string]any, req map[string]any) (*PagingResult[map[string]any], error)

func (*RawQuery) Query

func (r *RawQuery) Query(db *gorm.DB, data map[string]any) ([]map[string]any, error)

func (*RawQuery) ShouldPagingResult added in v0.10.18

func (r *RawQuery) ShouldPagingResult(req map[string]any) bool

check should return Paging Result

type RawQuerySerice

type RawQuerySerice struct {
	Source      string
	EnabledAuth bool
	Base        string
	Items       []SerivceItem
	// contains filtered or unexported fields
}

type RawQueryWhere added in v0.10.14

type RawQueryWhere struct {
	Cond  string
	Param string
	Empty string // optional settings, where condition for params is empty
}

it's not enabled yet.

type SerivceItem

type SerivceItem struct {
	Uri     string
	Query   RawQuery  // header
	Details *RawQuery // details
}

Jump to

Keyboard shortcuts

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