filter

package
v0.0.1-20240408-0001 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageNr       int64 = 1
	DefaultNrOfItems    int64 = 50
	DefaultMaxNrOfItems int64 = 1000
)

Variables

This section is empty.

Functions

func CountWords

func CountWords(s string) int

Types

type BeginsWith

type BeginsWith struct {
	Name            string `json:"Name"`
	Value           string `json:"Value"`
	CaseInsensitive *bool  `json:"CaseInsensitive"`
}

type Between

type Between struct {
	Name   string  `json:"Name"`
	Value1 *string `json:"Start"`
	Value2 *string `json:"End"`
}

type Condition

type Condition struct {
	Or *bool `json:"Or"`
	// Group       *GroupCondition `json:"Group"`
	Eq    *Eq    `json:"Eq"`
	NotEq *NotEq `json:"NotEqual"`

	Ht *Ht `json:"HigherThan"`
	He *He `json:"HigherOrEqual"`

	Lt *Lt `json:"LowerThan"`
	Le *Le `json:"LowerOrEqual"`

	Contains    *Contains    `json:"Contains"`
	NotContains *NotContains `json:"NotContains"`

	BeginsWith    *BeginsWith    `json:"BeginsWith"`
	NotBeginsWith *NotBeginsWith `json:"NotBeginsWith"`

	EndsWith    *EndsWith    `json:"EndsWith"`
	NotEndsWith *NotEndsWith `json:"NotEndsWith"`

	In    *In    `json:"In"`
	NotIn *NotIn `json:"NotIn"`

	IsNull  *IsNull  `json:"IsNull"`
	NotNull *NotNull `json:"IsNotNull"`

	IsTrue  *IsTrue  `json:"IsTrue"`
	IsFalse *IsFalse `json:"IsFalse"`

	Empty    *Empty    `json:"IsEmpty"`
	NotEmpty *NotEmpty `json:"IsNotEmpty"`

	Between    *Between    `json:"Between"`
	NotBetween *NotBetween `json:"NotBetween"`
}

type Contains

type Contains struct {
	Name            string `json:"Name"`
	Value           string `json:"Value"`
	CaseInsensitive *bool  `json:"CaseInsensitive"`
}

type Counters

type Counters struct {
	// how many items there are in the db without pagination
	TotalItems int64
	// how many pages there are based on the requested nr of items
	TotalPages int64
	// How many items have been requested
	RequestedNrOfItems int64
	// what is the requested page nr
	RequestedPageNr int64
	// how many items have been received from the server
	ReceivedNrOfItems int64
}

type DBField

type DBField struct {
	// only field name
	FieldName string
	// QuotedFieldName -> with ""
	QuotedFieldName string
	// field name with table name prefixed
	TableNameFieldName string
	// QuotedTableNameFieldName -> with ""
	QuotedTableNameFieldName string
}

type Details

type Details struct {
}

type Empty

type Empty struct {
	Name string `json:"Name"`
}

type EndsWith

type EndsWith struct {
	Name            string `json:"Name"`
	Value           string `json:"Value"`
	CaseInsensitive *bool  `json:"CaseInsensitive"`
}

type Eq

type Eq struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type Export

type Export struct {
	// This is a prefix for exporting/generating the file!
	ExportName string
	TableName  string
	Model      interface{}
	Columns    []ExportColumn
	Filter     *Input
	Preloads   []string
	// It will delete itself after a period of time...
	// if 0, then it will not be deleted!
	SelfDeleteAfterSeconds int64
	// contains filtered or unexported fields
}

func NewExport

func NewExport(e *Export) *Export

func (*Export) GenerateExcel

func (e *Export) GenerateExcel() bool

func (*Export) GeneratePdf

func (e *Export) GeneratePdf()

func (*Export) GetExcelCreatedAt

func (e *Export) GetExcelCreatedAt() time.Time

func (*Export) GetExcelError

func (e *Export) GetExcelError() error

func (*Export) GetExcelExportPath

func (e *Export) GetExcelExportPath() (string, error)

func (*Export) GetExcelFileExtension

func (e *Export) GetExcelFileExtension() string

func (*Export) GetExcelFileID

func (e *Export) GetExcelFileID() uuid.UUID

func (*Export) GetExcelFileName

func (e *Export) GetExcelFileName() string

func (*Export) GetExcelFileSizeBytes

func (e *Export) GetExcelFileSizeBytes() int64

func (*Export) GetExcelFullFileName

func (e *Export) GetExcelFullFileName() string

func (*Export) GetExcelFullFilePath

func (e *Export) GetExcelFullFilePath() string

func (*Export) GetHtmlExportPath

func (e *Export) GetHtmlExportPath() (string, error)

func (*Export) GetItems

func (e *Export) GetItems() interface{}

func (e *Export) GetItems() []map[string]interface{} {

func (*Export) GetJsonExportPath

func (e *Export) GetJsonExportPath() (string, error)

func (*Export) GetNrOfRows

func (e *Export) GetNrOfRows() int64

func (*Export) GetPdfExportPath

func (e *Export) GetPdfExportPath() (string, error)

func (*Export) GetWordExportPath

func (e *Export) GetWordExportPath() (string, error)

func (*Export) QueryItems

func (e *Export) QueryItems() error

func (*Export) SetColumns

func (e *Export) SetColumns(columns []ExportColumn) *Export

func (*Export) SetItems

func (e *Export) SetItems(items interface{}) *Export

func (e *Export) SetItems(items []map[string]interface{}) *Export {

type ExportColumn

type ExportColumn struct {
	// you can choose of these options: (it's the search criteria)
	FieldName string // it can contain .

	// This is the name of the column in the header
	HeaderName string
	Handler    ExportHandler
	ColWidth   float64
}

type ExportHandler

type ExportHandler func(row *ExportRow) ExportValue

type ExportRow

type ExportRow struct {
	ReflectVal reflect.Value
	RowMap     map[string]interface{}
	Row        interface{}
	FieldValue interface{}
}

func (*ExportRow) GetStructValue

func (e *ExportRow) GetStructValue(fieldName string) interface{}

type ExportValue

type ExportValue interface{}

type GroupCondition

type GroupCondition struct {
	Or         *bool             `json:"Or"`
	Conditions []*Condition      `json:"Conditions"`
	Groups     []*GroupCondition `json:"Groups"`
}

type GroupConditionInput

type GroupConditionInput struct {
	// This is the original clean DB Client
	//ODB *gorm.DB
	// This is the one that modifies...
	DB             *gorm.DB
	GroupCondition *GroupCondition
}

type He

type He struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type Ht

type Ht struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type In

type In struct {
	Name  string    `json:"Name"`
	Value []*string `json:"Value"`
}

type Input

type Input struct {
	PageNr    *int64 `json:"PageNr"`
	NrOfItems *int64 `json:"NrOfItems"`

	// it allows to go higher than 1000 limit!
	Order          []*Order        `json:"OrderBy"`
	Search         *string         `json:"Search"`
	RootConditions *GroupCondition `json:"RootConditions"`
	// contains filtered or unexported fields
}

func New

func New(f *Input) *Input

func (*Input) Apply

func (f *Input) Apply() *Input

func (*Input) ApplyConditions

func (f *Input) ApplyConditions() *Input

func (*Input) ApplyOrdering

func (f *Input) ApplyOrdering() *Input

func (*Input) ApplyPagination

func (f *Input) ApplyPagination() *Input

func (*Input) DB

func (f *Input) DB() *gorm.DB

func (*Input) DisableDBFieldsAutoCaching

func (f *Input) DisableDBFieldsAutoCaching() *Input

func (*Input) DisableDefaultScope

func (f *Input) DisableDefaultScope() *Input

func (*Input) EnableDBFieldsAutoCaching

func (f *Input) EnableDBFieldsAutoCaching() *Input

func (*Input) EnableDefaultScope

func (f *Input) EnableDefaultScope() *Input

func (*Input) GetNrOfItems

func (f *Input) GetNrOfItems() (*Counters, error)

func (*Input) NewInstanceWithConditions

func (f *Input) NewInstanceWithConditions() *Input

func (*Input) SetContext

func (f *Input) SetContext(ctx context.Context) *Input

func (*Input) SetCounterDB

func (f *Input) SetCounterDB(dbClient *gorm.DB) *Input

func (*Input) SetDB

func (f *Input) SetDB(db *gorm.DB) *Input

func (*Input) SetDb

func (f *Input) SetDb(dbClient *gorm.DB) *Input

func (*Input) SetMainDB

func (f *Input) SetMainDB(dbClient *gorm.DB) *Input

func (*Input) SetMaxNrOfItems

func (f *Input) SetMaxNrOfItems(maxNrOfItems int64) *Input

SetMaxNrOfItems -> this is the max allowed value that can be set when requesting... or the max value that will be taken in case of if NrOfItems is higher than this limit! -1 can also be set! -> this means it's ALL or unlimited!

func (*Input) SetModels

func (f *Input) SetModels(models ...InputModel) *Input

func (*Input) SetNrOfItems

func (f *Input) SetNrOfItems(nrOfItems int64) *Input

SetNrOfItems -> this is the requested nr of items!

func (*Input) SetPageNr

func (f *Input) SetPageNr(pageNr int64) *Input

type InputModel

type InputModel struct {
	Name  string
	Model interface{}

	// TableName -> used when using Joins, which automatically makes a relation to a custom table name!
	TableName string
}

type IsFalse

type IsFalse struct {
	Name string `json:"Name"`
}

type IsNull

type IsNull struct {
	Name string `json:"Name"`
}

type IsTrue

type IsTrue struct {
	Name string `json:"Name"`
}

type Le

type Le struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type Lt

type Lt struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type NotBeginsWith

type NotBeginsWith struct {
	Name            string `json:"Name"`
	Value           string `json:"Value"`
	CaseInsensitive *bool  `json:"CaseInsensitive"`
}

type NotBetween

type NotBetween struct {
	Name   string  `json:"Name"`
	Value1 *string `json:"Start"`
	Value2 *string `json:"End"`
}

type NotContains

type NotContains struct {
	Name            string `json:"Name"`
	Value           string `json:"Value"`
	CaseInsensitive *bool  `json:"CaseInsensitive"`
}

type NotEmpty

type NotEmpty struct {
	Name string `json:"Name"`
}

type NotEndsWith

type NotEndsWith struct {
	Name            string `json:"Name"`
	Value           string `json:"Value"`
	CaseInsensitive *bool  `json:"CaseInsensitive"`
}

type NotEq

type NotEq struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

type NotIn

type NotIn struct {
	Name  string    `json:"Name"`
	Value []*string `json:"Value"`
}

type NotNull

type NotNull struct {
	Name string `json:"Name"`
}

type Order

type Order struct {
	FieldName string  `json:"FieldName"`
	Direction *string `json:"Direction"`
}

type QueryStatement

type QueryStatement struct {
	Query interface{}
	Args  []interface{}
}

Jump to

Keyboard shortcuts

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