orm

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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