gworm

package
v0.0.0-...-77bf602 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConditionQueryPrefix = "condition{"
	ConditionQuerySuffix = "}"
	TagNameMulti         = "multi"
	TagNameWildcard      = "wildcard"
)

Variables

View Source
var (
	SortDirection_name = map[SortDirection]string{
		0: "ASC",
		1: "DESC",
	}
	SortDirection_value = map[string]SortDirection{
		"ASC":  0,
		"DESC": 1,
	}
)

Enum value maps for MultiType.

Functions

func WhereBetween

func WhereBetween(key string, min, max interface{}) *bson.E

func WhereEq

func WhereEq(key string, value interface{}) *bson.E

func WhereGT

func WhereGT(key string, value interface{}) *bson.E

func WhereGTE

func WhereGTE(key string, value interface{}) *bson.E

func WhereIn

func WhereIn(key string, value []interface{}) *bson.E

func WhereLT

func WhereLT(key string, value interface{}) *bson.E

func WhereLTE

func WhereLTE(key string, value interface{}) *bson.E

func WhereLike

func WhereLike(key string, like string) *bson.E

func WhereNotBetween

func WhereNotBetween(key string, min, max interface{}) *bson.E

func WhereNotEq

func WhereNotEq(key string, value interface{}) *bson.E

func WhereNotIn

func WhereNotIn(key string, value []interface{}) *bson.E

func WhereNotLike

func WhereNotLike(key string, like string) *bson.E

func WhereNotNull

func WhereNotNull(key string) *bson.E

func WhereNull

func WhereNull(key string) *bson.E

func WherePri

func WherePri(args []string) *bson.E

WherePri does the same logic as Model.Where except that if the parameter `where` is a single condition like int/string/float/slice, it treats the condition as the primary key value. That is, if primary key is "id" and given `where` parameter as "123", the WherePri function treats the condition as "id=123", but Model.Where treats the condition as string "123".

Types

type FilterRequest

type FilterRequest struct {
	PropertyFilters []*PropertyFilter
	Filters         *bson.D
}

func ExtractFilters

func ExtractFilters(ctx context.Context, req interface{}, columnMap map[string]string) (fr FilterRequest, err error)

func (*FilterRequest) GetFilters

func (fr *FilterRequest) GetFilters() (*bson.D, error)

type PageInfo

type PageInfo struct {
	Offset           int64       // the offset of the first element in current page of the paging request
	Size             int64       // page size of the paging request, may be larger than NumberOfElements
	Sorts            []SortParam // the sorting parameters of the paging request
	Number           int64       // page number of current page, starting from 1
	NumberOfElements int64       // number of elements in current page
	TotalElements    int64       // total number of elements for current request when without paging
	TotalPages       int64       // total number of pages of the paging request
	First            bool        // whether current page is first page
	Last             bool        // whether current page is last page
}

func (*PageInfo) From

func (pi *PageInfo) From(pageRequest *PageRequest, numberOfElement int64, totalElements int64)

type PageRequest

type PageRequest struct {
	Number int64

	Offset int64
	Size   int64
	Sorts  []SortParam
}

func NewPageRequest

func NewPageRequest(page, size int64, sort ...string) *PageRequest

func (*PageRequest) AddSort

func (pr *PageRequest) AddSort(sort SortParam) *PageRequest

func (*PageRequest) AddSortByString

func (pr *PageRequest) AddSortByString(sort string) *PageRequest

func (*PageRequest) HasSort

func (pr *PageRequest) HasSort() bool

func (*PageRequest) MongoSortOption

func (pr *PageRequest) MongoSortOption() (result bson.D)

func (*PageRequest) OrderString

func (pr *PageRequest) OrderString() string

type PropertyFilter

type PropertyFilter struct {
	Property string                   `json:"property"`
	Value    interface{}              `json:"value"`
	Operator goguruTypes.OperatorType `json:"operator"`
	Multi    goguruTypes.MultiType    `json:"multi"`
	Wildcard goguruTypes.WildcardType `json:"wildcard"`
}

type SortDirection

type SortDirection uint8

todo make all struct protobuf defined

const (
	SortDirection_ASC  SortDirection = 0
	SortDirection_DESC SortDirection = 1
)

type SortParam

type SortParam struct {
	Property  string
	Direction SortDirection
}

Jump to

Keyboard shortcuts

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