query

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConstantsQueryAccessTokenKeys = []string{
	"access_token",
	"accessToken",
}

ConstantsQueryAccessTokenKeys is the keys that are used to identify the access token.

View Source
var ConstantsQueryIDKeys = []string{
	"id",
	"_id",
}

ConstantsQueryIDKeys is the keys that are used to identify the id.

View Source
var ConstantsQueryPageSizeKeys = []string{
	"page_size",
	"pageSize",
}

ConstantsQueryPageSizeKeys is the keys that are used to identify the page size.

View Source
var ConstantsWHereIgnoreKeys = []string{
	"page",
	"page_size",
	"pageSize",
	"order_by",
	"orderBy",
}

ConstantsWHereIgnoreKeys is the keys that are ignored.

Functions

This section is empty.

Types

type OrderBy added in v1.16.0

type OrderBy []OrderByOne

OrderBy is a list of order bys.

func (*OrderBy) Add added in v1.16.0

func (w *OrderBy) Add(key string, IsDESC bool)

Add adds a order by.

func (*OrderBy) AddClause added in v1.16.0

func (w *OrderBy) AddClause(clause string)

AddClause adds a order by clause.

func (*OrderBy) Build added in v1.16.0

func (w *OrderBy) Build() string

Build builds the order bys.

func (*OrderBy) Debug added in v1.16.0

func (w *OrderBy) Debug()

Debug prints the order bys.

func (*OrderBy) Del added in v1.16.0

func (w *OrderBy) Del(key string)

Del deletes a order by.

func (*OrderBy) Get added in v1.16.0

func (w *OrderBy) Get(key string) (bool, bool)

Get gets a order by.

func (*OrderBy) GetClause added in v1.16.0

func (w *OrderBy) GetClause(key string) string

GetClause gets the order by clause.

func (*OrderBy) Length added in v1.16.0

func (w *OrderBy) Length() int

Length returns the length of the order bys.

func (*OrderBy) Reset added in v1.16.0

func (w *OrderBy) Reset()

Reset resets the order bys.

func (*OrderBy) Set added in v1.16.0

func (w *OrderBy) Set(key string, IsDESC bool)

Set sets a order by.

type OrderByOne added in v1.16.0

type OrderByOne struct {
	Key    string
	IsDESC bool
	// contains filtered or unexported fields
}

OrderByOne is a single order by.

func (*OrderByOne) Clause added in v1.16.0

func (w *OrderByOne) Clause() string

Clause returns the clause of the order by.

func (*OrderByOne) String added in v1.16.0

func (w *OrderByOne) String() string

String returns the string of the order by.

type Query

type Query interface {
	Get(key string, defaultValue ...string) strings.Value
	//
	Page(defaultValue ...uint) uint
	PageSize(defaultValue ...uint) uint
	Where() *Where
	OrderBy() *OrderBy
	//
	ID() (id strings.Value, err error)
	MustID() (id strings.Value)
	AccessToken() (accessToken string, err error)
	MustAccessToken() (accessToken string)
}

Query ...

func New

func New(request *http.Request) Query

New creates a query.

type SetWhereOptions added in v1.16.0

type SetWhereOptions struct {
	IsEqual              bool
	IsNotEqual           bool
	IsFuzzy              bool
	IsIn                 bool
	IsNotIn              bool
	IsPlain              bool
	IsFullTextSearch     bool
	FullTextSearchFields []string
}

SetWhereOptions is the options for SetWhere.

type Where added in v1.16.0

type Where struct {
	Items []WhereOne
	//
	FullTextSearchFields []string
}

Where is the where.

func (*Where) Add added in v1.16.0

func (w *Where) Add(key string, value interface{}, opts ...*SetWhereOptions)

Add adds a where, if exists, append.

func (*Where) Build added in v1.16.0

func (w *Where) Build() (query string, args []interface{}, err error)

Build builds the wheres.

func (*Where) Debug added in v1.16.0

func (w *Where) Debug()

Debug prints the wheres.

func (*Where) Del added in v1.16.0

func (w *Where) Del(key string)

Del deletes a where.

func (*Where) Get added in v1.16.0

func (w *Where) Get(key string) (interface{}, bool)

Get gets a where.

func (*Where) Length added in v1.16.0

func (w *Where) Length() int

Length returns the length of the wheres.

func (*Where) Reset added in v1.16.0

func (w *Where) Reset()

Reset resets the wheres.

func (*Where) Set added in v1.16.0

func (w *Where) Set(key string, value interface{}, opts ...*SetWhereOptions)

Set sets a where, if exists, update.

type WhereOne added in v1.16.0

type WhereOne struct {
	Key   string
	Value interface{}

	// IsEqual => =
	IsEqual bool
	// IsNotEqual => !=
	IsNotEqual bool

	// IsFuzzy => ILike
	IsFuzzy bool

	// IsIn => in (?)
	IsIn bool
	// IsNotIn => not in (?)
	IsNotIn bool

	// IsPlain => plain
	IsPlain bool

	// IsFullTextSearch => ILike (field1) OR ILike (field2) OR ...
	IsFullTextSearch     bool
	FullTextSearchFields []string
}

WhereOne is the where one.

Jump to

Keyboard shortcuts

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