orm

package
v0.0.0-...-678c32f Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: Apache-2.0 Imports: 2 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(o interface{}) (int, error)

func Delete

func Delete(o interface{}) error

func Get

func Get(o interface{}) error

func GroupBy

func GroupBy(o interface{}, selectField, groupField, haveQuery string, haveValue interface{}) (error, map[string]interface{})

func Register

func Register(name string, h ORM)

func RegisterSchema

func RegisterSchema(t interface{}) error

func Save

func Save(o interface{}) error

func Update

func Update(o interface{}) error

Types

type BoolType

type BoolType string
const Must BoolType = "must"
const MustNot BoolType = "must_not"
const Should BoolType = "should"

type Cond

type Cond struct {
	Field       string
	SQLOperator string
	QueryType   QueryType
	BoolType    BoolType
	Value       interface{}
}

func And

func And(conds ...*Cond) []*Cond

func Combine

func Combine(conds ...[]*Cond) []*Cond

func Eq

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

func Ge

func Ge(field string, value interface{}) *Cond

func Gt

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

func Le

func Le(field string, value interface{}) *Cond

func Lt

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

func NotEq

func NotEq(field string, value interface{}) *Cond

type ORM

type ORM interface {
	RegisterSchema(t interface{}) error

	Save(o interface{}) error

	Update(o interface{}) error

	Delete(o interface{}) error

	Search(t interface{}, to interface{}, q *Query) (error, Result)

	Get(o interface{}) error

	GetBy(field string, value interface{}, t interface{}, to interface{}) (error, Result)

	Count(o interface{}) (int, error)

	GroupBy(o interface{}, selectField, groupField string, haveQuery string, haveValue interface{}) (error, map[string]interface{})
}

type Query

type Query struct {
	Sort     *[]Sort
	From     int
	Size     int
	Conds    []*Cond
	RawQuery string
}

type QueryType

type QueryType string
const Match QueryType = "match"
const RangeGt QueryType = "gt"
const RangeGte QueryType = "gte"
const RangeLt QueryType = "lt"
const RangeLte QueryType = "lte"

type Result

type Result struct {
	Total  int
	Result interface{}
}

func GetBy

func GetBy(field string, value interface{}, t interface{}, to interface{}) (error, Result)
func Search(t interface{}, to interface{}, q *Query) (error, Result)

type Sort

type Sort struct {
	Field    string
	SortType SortType
}

type SortType

type SortType string
const ASC SortType = "asc"
const DESC SortType = "desc"

Jump to

Keyboard shortcuts

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