models

package
v0.0.0-...-e8a8f99 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PaginationColumns = struct {
	Deleted   string
	TimeRange string
}{
	Deleted:   "excludeInactived",
	TimeRange: "timeRange",
}

PaginationColumns defines all columns var for orm pagination.

Functions

func Attach

func Attach(c *Condition) func(db *gorm.DB) *gorm.DB

Attach returns the attached db with input condition. Note: will attach fields by go interface assertion.

func Paginate

func Paginate(p *Pagination) func(db *gorm.DB) *gorm.DB

Paginate returns a func with paging infomation. Ideally, the func includes: offset, limit, created_at, actived.

Types

type Attachment

type Attachment map[string]interface{}

Attachment alias of map[string]interface{}

type Collection

type Collection struct {
	Values []interface{}
}

Collection wrapper slice condition.

type Condition

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

Condition builder the model query limit conditions.

func (*Condition) AddJSONQueries

func (c *Condition) AddJSONQueries(qs ...InnerDetector)

AddJSONQueries adder of jsonQueries.

func (*Condition) GetAttachmentOrNil

func (c *Condition) GetAttachmentOrNil(k string) (interface{}, bool)

GetAttachmentOrNil returns (interface{}, bool) pair of key.

func (*Condition) GetEndTime

func (c *Condition) GetEndTime() uint64

GetEndTime getter of to.

func (*Condition) GetJSONQueries

func (c *Condition) GetJSONQueries() []InnerDetector

GetJSONQueries getter of jsonQueries.

func (*Condition) GetStartTime

func (c *Condition) GetStartTime() uint64

GetStartTime getter of from.

func (*Condition) IsExcludeInactived

func (c *Condition) IsExcludeInactived() bool

IsExcludeInactived getter of excludeInactived.

func (*Condition) SetAttachment

func (c *Condition) SetAttachment(attachment Attachment)

SetAttachment setter of attachment.

func (*Condition) SetExcludeInactived

func (c *Condition) SetExcludeInactived(excludeInactived bool)

SetExcludeInactived setter of excludeInactived.

func (*Condition) SetTimeRange

func (c *Condition) SetTimeRange(r Uint64Range)

SetTimeRange setter includes from, to.

type InnerDetector

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

InnerDetector extension detector for mysql#Json or PSql#Jsonb field type.

func (*InnerDetector) GetField

func (i *InnerDetector) GetField() string

GetField getter of field.

func (*InnerDetector) GetKey1

func (i *InnerDetector) GetKey1() string

GetKey1 getter of key1.

func (*InnerDetector) GetKey2

func (i *InnerDetector) GetKey2() string

GetKey2 getter of key2.

func (*InnerDetector) GetLevel

func (i *InnerDetector) GetLevel() int8

GetLevel getter of level.

func (*InnerDetector) GetValue

func (i *InnerDetector) GetValue() interface{}

GetValue getter of value.

func (InnerDetector) SetLevel1

func (i InnerDetector) SetLevel1(field, key1 string, value interface{}) InnerDetector

SetLevel1 setter self to level 1.

func (InnerDetector) SetLevel2

func (i InnerDetector) SetLevel2(field, key1, key2 string, value interface{}) InnerDetector

SetLevel2 setter self to level 2.

type Order

type Order string

Order type for order

const (
	ASC  Order = "ASC"
	DESC Order = "DESC"
)

Orders

type Pagination

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

Pagination builder the info of paginate.

func NewPagination

func NewPagination() *Pagination

NewPagination returns default obj of Pagination.

func (*Pagination) BuildCondition

func (p *Pagination) BuildCondition() *Condition

BuildCondition builder func of condition.

func (*Pagination) GetAttachment

func (p *Pagination) GetAttachment() Attachment

GetAttachment getter of attachment.

func (*Pagination) GetPage

func (p *Pagination) GetPage() int

GetPage getter of page.

func (*Pagination) GetPageSize

func (p *Pagination) GetPageSize() int

GetPageSize geeter of pageSize.

func (*Pagination) SetAttachment

func (p *Pagination) SetAttachment(a Attachment)

SetAttachment setter of attachment.

func (*Pagination) SetPage

func (p *Pagination) SetPage(page int)

SetPage setter of page.

func (*Pagination) SetPageSize

func (p *Pagination) SetPageSize(pageSize int)

SetPageSize setter of pageSize.

type Response

type Response struct {
	Page      int
	TotalPage int
	Total     int
	Data      interface{}
}

Response wrapper the pagination result.

type Uint64Range

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

Uint64Range wrapper range condition.

func (Uint64Range) Default

func (r Uint64Range) Default() Uint64Range

Default return default obj.

func (*Uint64Range) GetLeft

func (r *Uint64Range) GetLeft() uint64

GetLeft gtter of left.

func (*Uint64Range) GetRight

func (r *Uint64Range) GetRight() uint64

GetRight getter of right.

func (Uint64Range) Set

func (r Uint64Range) Set(left, right uint64) Uint64Range

Set setter of left and right.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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