gworm

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

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

todo gworm package is deprecated

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

This section is empty.

Types

type FilterRequest

type FilterRequest struct {
	PropertyFilters []*PropertyFilter
}

func ExtractFilters

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

func (*FilterRequest) AddPropertyFilter

func (fr *FilterRequest) AddPropertyFilter(f *PropertyFilter) *FilterRequest

type Model

type Model struct {
	Type       ModelType
	GfModel    *gdb.Model
	MongoModel *mongodb.Model
}

func AddCondition

func AddCondition(_ context.Context, columnName string, condition *PropertyFilter, m *Model) (*Model, error)

func AddCondition1

func AddCondition1(columnName string, condition *gwtypes.Condition, m *Model) (*Model, error)

func ApplyFilter

func ApplyFilter(ctx context.Context, request FilterRequest, m *Model) (output *Model, err error)

func ApplyPropertyFilter

func ApplyPropertyFilter(_ context.Context, condition *PropertyFilter, m *Model) (*Model, error)

func ParseConditions

func ParseConditions(ctx context.Context, req interface{}, columnMap map[string]string, m *Model) (*Model, error)

ParseConditions 根据传入 query 结构指针的值来设定 Where 条件 ctx context queryPtr 传入 query 结构指针的值 columnMap 表的字段定义map,key为GoField,value为表字段名 m gdb.Model

func (*Model) Count

func (m *Model) Count(ctx context.Context) (int64, error)

func (*Model) Delete

func (m *Model) Delete(ctx context.Context, where ...interface{}) (*Result, error)

func (*Model) Fields

func (m *Model) Fields(fieldNamesOrMapStruct ...interface{}) *Model

func (*Model) FieldsEx

func (m *Model) FieldsEx(fieldNamesOrMapStruct ...interface{}) *Model

func (*Model) InsertOne

func (m *Model) InsertOne(ctx context.Context, req interface{}) (*Result, error)

func (*Model) Limit

func (m *Model) Limit(limit ...int) *Model

func (*Model) Order

func (m *Model) Order(orderBy ...interface{}) *Model

func (*Model) Page

func (m *Model) Page(page, limit int) *Model

func (*Model) Scan

func (m *Model) Scan(ctx context.Context, pointer interface{}, where ...interface{}) error

func (*Model) Update

func (m *Model) Update(ctx context.Context, data interface{}) (*Result, error)

func (*Model) Upsert

func (m *Model) Upsert(ctx context.Context, data interface{}) (*Result, error)

func (*Model) Where

func (m *Model) Where(where interface{}, args ...interface{}) *Model

func (*Model) WhereBetween

func (m *Model) WhereBetween(column string, min, max interface{}) *Model

func (*Model) WhereGT

func (m *Model) WhereGT(column string, value interface{}) *Model

func (*Model) WhereGTE

func (m *Model) WhereGTE(column string, value interface{}) *Model

func (*Model) WhereIn

func (m *Model) WhereIn(column string, in interface{}) *Model

func (*Model) WhereLT

func (m *Model) WhereLT(column string, value interface{}) *Model

func (*Model) WhereLTE

func (m *Model) WhereLTE(column string, value interface{}) *Model

func (*Model) WhereLike

func (m *Model) WhereLike(column string, like string) *Model

func (*Model) WhereNot

func (m *Model) WhereNot(column string, value interface{}) *Model

func (*Model) WhereNotBetween

func (m *Model) WhereNotBetween(column string, min, max interface{}) *Model

func (*Model) WhereNotIn

func (m *Model) WhereNotIn(column string, in interface{}) *Model

func (*Model) WhereNotLike

func (m *Model) WhereNotLike(column string, like string) *Model

func (*Model) WhereNotNull

func (m *Model) WhereNotNull(column ...string) *Model

func (*Model) WhereNull

func (m *Model) WhereNull(column ...string) *Model

func (*Model) WherePri

func (m *Model) WherePri(where interface{}, args ...interface{}) *Model

func (*Model) WithAll

func (m *Model) WithAll() *Model

type ModelType

type ModelType uint8
const (
	// GF_ORM GoFrame ORM
	GF_ORM ModelType = iota
	// MONGO MongoDB via native driver
	MONGO
)

type PageInfo

type PageInfo struct {
	Offset           uint64      // the offset of the first element in current page of the paging request
	Size             uint32      // page size of the paging request, may be larger than NumberOfElements
	Sorts            []SortParam // the sorting parameters of the paging request
	Number           uint32      // page number of current page, starting from 1
	NumberOfElements uint32      // number of elements in current page
	TotalElements    uint64      // total number of elements for current request when without paging
	TotalPages       uint32      // 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 uint32, totalElements uint64)

type PageRequest

type PageRequest struct {
	Number uint32

	Offset uint64
	Size   uint32
	Sorts  []SortParam
}

func (PageRequest) AddSort

func (pr PageRequest) AddSort(sort SortParam) PageRequest

func (PageRequest) AddSortByString

func (pr PageRequest) AddSortByString(sort string) PageRequest

func (PageRequest) Of

func (pr PageRequest) Of(page, size uint32, sort ...SortParam) PageRequest

func (PageRequest) OrderString

func (pr PageRequest) OrderString() string

type PropertyFilter

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

func AddConditionFilter

func AddConditionFilter(columnName string, condition *gwtypes.Condition, mType ModelType) (pf *PropertyFilter, err error)

type Result

type Result struct {
	Type           ModelType
	SqlResult      sql.Result
	MongoResult    *mongodb.MongoResult
	LastInsertedId string
	RowsAffected   int64
}

type SortDirection

type SortDirection uint8
const (
	SortDirection_ASC  SortDirection = 0
	SortDirection_DESC SortDirection = 1
)

type SortParam

type SortParam struct {
	Property  string
	Direction SortDirection
}

Directories

Path Synopsis
internal/reflection
Package reflection provides some reflection functions for internal usage.
Package reflection provides some reflection functions for internal usage.

Jump to

Keyboard shortcuts

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