query

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrColumnNotFound = errors.New("column not found")
	ErrRowNotFound    = errors.New("row not found")
)

Functions

This section is empty.

Types

type AggregateResult

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

AggregateResult 聚合结果

type Condition

type Condition struct {
	Column string
	Op     string // "=", "!=", ">", "<", ">=", "<=", "like"
	Value  string
}

type Query

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

func New

func New(path string) *Query

func (*Query) Find

func (q *Query) Find(cond Condition) ([][]string, error)

Find 单条件查询,直接返回结果

func (*Query) FindAll

func (q *Query) FindAll(conds ...Condition) *Result

FindAll 多条件查询,返回 Result 支持链式处理

func (*Query) FindIn

func (q *Query) FindIn(column string, values []string) ([][]string, error)

FindIn IN 查询

func (*Query) FindNotIn

func (q *Query) FindNotIn(column string, values []string) ([][]string, error)

FindNotIn NOT IN 查询

type Result

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

Result 查询结果,支持链式处理

func (*Result) Avg

func (r *Result) Avg(column string) (float64, error)

Avg 计算指定列的平均值

func (*Result) Count

func (r *Result) Count() (int, error)

Count 统计结果数量

func (*Result) Exists

func (r *Result) Exists() (bool, error)

Exists 判断是否存在匹配结果

func (*Result) First

func (r *Result) First() ([]string, error)

First 获取第一条结果

func (*Result) Get

func (r *Result) Get() ([][]string, error)

Get 获取所有结果

func (*Result) Limit

func (r *Result) Limit(n int) *Result

Limit 限制结果数量

func (*Result) Max

func (r *Result) Max(column string) (string, error)

Max 获取指定列的最大值(字符串比较)

func (*Result) MaxFloat

func (r *Result) MaxFloat(column string) (float64, error)

MaxFloat 获取指定列的最大值(数值比较)

func (*Result) Min

func (r *Result) Min(column string) (string, error)

Min 获取指定列的最小值(字符串比较)

func (*Result) MinFloat

func (r *Result) MinFloat(column string) (float64, error)

MinFloat 获取指定列的最小值(数值比较)

func (*Result) Offset

func (r *Result) Offset(n int) *Result

Offset 跳过前 N 条

func (*Result) OrderBy

func (r *Result) OrderBy(column, order string) *Result

OrderBy 单列排序

func (*Result) Select

func (r *Result) Select(columns ...string) *Result

Select 选择特定列

func (*Result) Sum

func (r *Result) Sum(column string) (float64, error)

Sum 计算指定列的总和

func (*Result) ThenBy

func (r *Result) ThenBy(column, order string) *Result

ThenBy 多列排序,追加排序条件

Jump to

Keyboard shortcuts

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