filter

package
v0.0.0-...-9d0e06d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Direction_name = map[int32]string{
		0: "ASC",
		1: "DESC",
	}
	Direction_value = map[string]int32{
		"ASC":  0,
		"DESC": 1,
	}
)

Enum value maps for Direction.

View Source
var (
	Operator_name = map[int32]string{
		0: "Equals",
		1: "Contains",
		2: "Starts",
		3: "In",
		4: "Gt",
		5: "Gte",
		6: "Lt",
		7: "Lte",
	}
	Operator_value = map[string]int32{
		"Equals":   0,
		"Contains": 1,
		"Starts":   2,
		"In":       3,
		"Gt":       4,
		"Gte":      5,
		"Lt":       6,
		"Lte":      7,
	}
)

Enum value maps for Operator.

View Source
var File_filter_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Condition

type Condition struct {
	FieldName      string   `protobuf:"bytes,1,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"`
	Operator       Operator `protobuf:"varint,2,opt,name=operator,proto3,enum=Operator" json:"operator,omitempty"`
	Value          string   `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
	Not            bool     `protobuf:"varint,4,opt,name=not,proto3" json:"not,omitempty"`
	FilterOperator string   `protobuf:"bytes,5,opt,name=filter_operator,json=filterOperator,proto3" json:"filter_operator,omitempty"`
	// contains filtered or unexported fields
}

func (*Condition) Descriptor deprecated

func (*Condition) Descriptor() ([]byte, []int)

Deprecated: Use Condition.ProtoReflect.Descriptor instead.

func (*Condition) GetFieldName

func (x *Condition) GetFieldName() string

func (*Condition) GetFilterOperator

func (x *Condition) GetFilterOperator() string

func (*Condition) GetNot

func (x *Condition) GetNot() bool

func (*Condition) GetOperator

func (x *Condition) GetOperator() Operator

func (*Condition) GetValue

func (x *Condition) GetValue() string

func (*Condition) ProtoMessage

func (*Condition) ProtoMessage()

func (*Condition) ProtoReflect

func (x *Condition) ProtoReflect() protoreflect.Message

func (*Condition) Reset

func (x *Condition) Reset()

func (*Condition) String

func (x *Condition) String() string

type Direction

type Direction int32
const (
	Direction_ASC  Direction = 0
	Direction_DESC Direction = 1
)

func (Direction) Descriptor

func (Direction) Descriptor() protoreflect.EnumDescriptor

func (Direction) Enum

func (x Direction) Enum() *Direction

func (Direction) EnumDescriptor deprecated

func (Direction) EnumDescriptor() ([]byte, []int)

Deprecated: Use Direction.Descriptor instead.

func (Direction) Number

func (x Direction) Number() protoreflect.EnumNumber

func (Direction) String

func (x Direction) String() string

func (Direction) Type

type Filter

type Filter struct {
	MainFilter   string       `protobuf:"bytes,1,opt,name=main_filter,json=mainFilter,proto3" json:"main_filter,omitempty"`
	SelectFields []string     `protobuf:"bytes,2,rep,name=select_fields,json=selectFields,proto3" json:"select_fields,omitempty"`
	Ids          []string     `protobuf:"bytes,3,rep,name=ids,proto3" json:"ids,omitempty"`
	Conditions   []*Condition `protobuf:"bytes,4,rep,name=conditions,proto3" json:"conditions,omitempty"`
	Orconditions []*Condition `protobuf:"bytes,5,rep,name=Orconditions,proto3" json:"Orconditions,omitempty"`
	OrderBy      []*OrderBy   `protobuf:"bytes,6,rep,name=orderBy,proto3" json:"orderBy,omitempty"`
	Limit        int64        `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"`
	Skip         int64        `protobuf:"varint,8,opt,name=skip,proto3" json:"skip,omitempty"`
	First        int64        `protobuf:"varint,9,opt,name=first,proto3" json:"first,omitempty"`
	Last         int64        `protobuf:"varint,10,opt,name=last,proto3" json:"last,omitempty"`
	// // free field to be sent filter compatible with Filter implementation
	RawFilter string `protobuf:"bytes,11,opt,name=rawFilter,proto3" json:"rawFilter,omitempty"`
	//	// add raw conditions to be sent to Filter implementation
	//	string rawConditions = 11;
	//
	//	// this field can be used to add "additional conditions", similar to where clause in SQL language
	//	repeated string additionalConditions = 12;
	//
	// some implementations use soft delete, this field would help the Filter implementation to decide how the filter
	//
	//	including records "deleted"
	IgnoreSoftDelete bool `protobuf:"varint,12,opt,name=ignoreSoftDelete,proto3" json:"ignoreSoftDelete,omitempty"`
	// contains filtered or unexported fields
}

generic filter API specification

func NewFilter

func NewFilter(mainFilter string) (q Filter)

func (*Filter) AddCondition

func (q *Filter) AddCondition(condition *Condition) *Filter

func (*Filter) AddOrderBy

func (q *Filter) AddOrderBy(field string, direction Direction) *Filter

func (*Filter) Contains

func (q *Filter) Contains(field, value string) *Filter

func (*Filter) Descriptor deprecated

func (*Filter) Descriptor() ([]byte, []int)

Deprecated: Use Filter.ProtoReflect.Descriptor instead.

func (*Filter) Eq

func (q *Filter) Eq(field string, value interface{}) *Filter

func (*Filter) From

func (q *Filter) From(tableName string) *Filter

func (*Filter) FullSearch

func (q *Filter) FullSearch(value any, fields ...string) *Filter

FullSearch is a special function to search by many fields at once using OR logical Operator

func (*Filter) GetConditions

func (x *Filter) GetConditions() []*Condition

func (*Filter) GetFirst

func (x *Filter) GetFirst() int64

func (*Filter) GetIds

func (x *Filter) GetIds() []string

func (*Filter) GetIgnoreSoftDelete

func (x *Filter) GetIgnoreSoftDelete() bool

func (*Filter) GetLast

func (x *Filter) GetLast() int64

func (*Filter) GetLimit

func (x *Filter) GetLimit() int64

func (*Filter) GetMainFilter

func (x *Filter) GetMainFilter() string

func (*Filter) GetOrconditions

func (x *Filter) GetOrconditions() []*Condition

func (*Filter) GetOrderBy

func (x *Filter) GetOrderBy() []*OrderBy

func (*Filter) GetRawFilter

func (x *Filter) GetRawFilter() string

func (*Filter) GetSelectFields

func (x *Filter) GetSelectFields() []string

func (*Filter) GetSkip

func (x *Filter) GetSkip() int64

func (*Filter) Gt

func (q *Filter) Gt(field string, value interface{}) *Filter

func (*Filter) Gte

func (q *Filter) Gte(field string, value interface{}) *Filter

func (*Filter) In

func (q *Filter) In(field string, value ...interface{}) *Filter

func (*Filter) Lt

func (q *Filter) Lt(field string, value interface{}) *Filter

func (*Filter) Lte

func (q *Filter) Lte(field string, value interface{}) *Filter

func (*Filter) Ne

func (q *Filter) Ne(field string, value interface{}) *Filter

func (*Filter) NotIn

func (q *Filter) NotIn(field string, value ...*anypb.Any) *Filter

func (*Filter) OrderByAsc

func (q *Filter) OrderByAsc(field string) *Filter

func (*Filter) OrderByDesc

func (q *Filter) OrderByDesc(field string) *Filter

func (*Filter) ProtoMessage

func (*Filter) ProtoMessage()

func (*Filter) ProtoReflect

func (x *Filter) ProtoReflect() protoreflect.Message

func (*Filter) Reset

func (x *Filter) Reset()

func (*Filter) Select

func (q *Filter) Select(field ...string) *Filter

func (*Filter) StartsOrContain

func (q *Filter) StartsOrContain(field, value string) *Filter

StartsOrContain funcao para consultar comecando com ou contendo o valor, se houver * no valor, ele consulta por contém, caso contrário consulta por start

func (*Filter) StartsWith

func (q *Filter) StartsWith(field, value string) *Filter

func (*Filter) String

func (x *Filter) String() string

type Operator

type Operator int32
const (
	Operator_Equals   Operator = 0
	Operator_Contains Operator = 1
	Operator_Starts   Operator = 2
	Operator_In       Operator = 3
	Operator_Gt       Operator = 4
	Operator_Gte      Operator = 5
	Operator_Lt       Operator = 6
	Operator_Lte      Operator = 7
)

func (Operator) Descriptor

func (Operator) Descriptor() protoreflect.EnumDescriptor

func (Operator) Enum

func (x Operator) Enum() *Operator

func (Operator) EnumDescriptor deprecated

func (Operator) EnumDescriptor() ([]byte, []int)

Deprecated: Use Operator.Descriptor instead.

func (Operator) Number

func (x Operator) Number() protoreflect.EnumNumber

func (Operator) String

func (x Operator) String() string

func (Operator) Type

type OrderBy

type OrderBy struct {
	FieldName string    `protobuf:"bytes,1,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"`
	Direction Direction `protobuf:"varint,2,opt,name=direction,proto3,enum=Direction" json:"direction,omitempty"`
	// contains filtered or unexported fields
}

func (*OrderBy) Descriptor deprecated

func (*OrderBy) Descriptor() ([]byte, []int)

Deprecated: Use OrderBy.ProtoReflect.Descriptor instead.

func (*OrderBy) GetDirection

func (x *OrderBy) GetDirection() Direction

func (*OrderBy) GetFieldName

func (x *OrderBy) GetFieldName() string

func (*OrderBy) ProtoMessage

func (*OrderBy) ProtoMessage()

func (*OrderBy) ProtoReflect

func (x *OrderBy) ProtoReflect() protoreflect.Message

func (*OrderBy) Reset

func (x *OrderBy) Reset()

func (*OrderBy) String

func (x *OrderBy) String() string

Jump to

Keyboard shortcuts

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