mworm

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 17 Imported by: 0

README

mworm

go postgresql orm

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SqlxDB  *sqlx.DB
	TagName = "db"
)

Functions

func Batch

func Batch(ormArray ...*OrmModel) error

func BatchArray

func BatchArray(ormArray []*OrmModel) error

func BatchFunc

func BatchFunc(f func(tx *sqlx.Tx)) error

func BindDB

func BindDB(DB *sqlx.DB) error

func ConvertArray added in v0.1.6

func ConvertArray[T int | string](array []T) []string

func NamedExec

func NamedExec(sqlStr string, params map[string]interface{}) error

func NamedQuery added in v0.1.4

func NamedQuery(query string, params any, dest any) error

func Query added in v0.1.4

func Query(query string, dest any) error

func RawSQL

func RawSQL(sql string, args ...interface{}) error

func StructToMap

func StructToMap(item interface{}) (map[string]interface{}, map[string]string)

func UnmarshalGetPath

func UnmarshalGetPath(json []byte, val interface{}, path ...interface{}) error

Types

type CRUDInterface

type CRUDInterface interface {
	CRUDMode(mode string) string
}

type ConditionGroup

type ConditionGroup struct {
	Logic        string
	JsonTags     []string
	Args         []any
	InArgs       []string
	NamedExpress string
	IsNull       bool
}

func And

func And(jsonTag ...string) ConditionGroup

func And2F

func And2F(jsonTag string, arg any) ConditionGroup

func Exp

func Exp(express string, args ...any) ConditionGroup

Exp 条件表达式 {table_column_field}=:{name}

func IN

func IN[T int | string](jsonTag string, args ...T) ConditionGroup

func ISNull

func ISNull(jsonTag ...string) ConditionGroup

ISNull 是否为空 And

func ISNullOr

func ISNullOr(jsonTag ...string) ConditionGroup

ISNullOr 是否为空 Or

func Or

func Or(jsonTag ...string) ConditionGroup

func Or2F

func Or2F(jsonTag string, args ...any) ConditionGroup

func (ConditionGroup) Transform

func (cg ConditionGroup) Transform() string

type ORMInterface

type ORMInterface interface {
	TableName() string
}

type OrmModel

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

func DELETE

func DELETE(i ORMInterface) *OrmModel

func INSERT

func INSERT(i ORMInterface) *OrmModel

func O added in v0.1.4

func O() *OrmModel

func SELECT

func SELECT(i ORMInterface) *OrmModel

func Table

func Table(name string) *OrmModel

func UPDATE

func UPDATE(i ORMInterface) *OrmModel

func (*OrmModel) Asc

func (o *OrmModel) Asc(jsonTag ...string) *OrmModel

func (*OrmModel) Count

func (o *OrmModel) Count(column string) (int64, error)

func (*OrmModel) Delete

func (o *OrmModel) Delete(i interface{}) *OrmModel

func (*OrmModel) Desc

func (o *OrmModel) Desc(jsonTag ...string) *OrmModel

func (*OrmModel) EmptyKey

func (o *OrmModel) EmptyKey(f bool) *OrmModel

func (*OrmModel) Error

func (o *OrmModel) Error() error

func (*OrmModel) Exclude

func (o *OrmModel) Exclude(jsonTag ...string) *OrmModel

func (*OrmModel) Exec

func (o *OrmModel) Exec() error

Exec 执行由 OrmModel 生成的 SQL 查询,并在出现错误时返回错误。

该函数不接受任何参数。 它返回一个错误。

func (*OrmModel) Fields

func (o *OrmModel) Fields(jsonTag ...string) *OrmModel

func (*OrmModel) Get

func (o *OrmModel) Get(dest interface{}) error

func (*OrmModel) If

func (o *OrmModel) If(ifFunc func(o *OrmModel)) *OrmModel

func (*OrmModel) Insert

func (o *OrmModel) Insert(i interface{}) *OrmModel

func (*OrmModel) JsonbList

func (o *OrmModel) JsonbList(dest interface{}) error

func (*OrmModel) JsonbListString

func (o *OrmModel) JsonbListString() (string, error)

func (*OrmModel) JsonbMap

func (o *OrmModel) JsonbMap(dest interface{}, columns ...string) error

func (*OrmModel) JsonbMapString

func (o *OrmModel) JsonbMapString(keys ...string) (string, error)

func (*OrmModel) Limit

func (o *OrmModel) Limit(row int64) *OrmModel

func (*OrmModel) List

func (o *OrmModel) List(dest interface{}) error

func (*OrmModel) Log

func (o *OrmModel) Log(l bool) *OrmModel

func (*OrmModel) NamedSQL

func (o *OrmModel) NamedSQL() string

func (*OrmModel) Offset

func (o *OrmModel) Offset(row int64) *OrmModel

func (*OrmModel) RETURNING

func (o *OrmModel) RETURNING(single any, list any, jsonTag ...string) error

func (*OrmModel) SQL

func (o *OrmModel) SQL() string

func (*OrmModel) Select

func (o *OrmModel) Select(i interface{}) *OrmModel

func (*OrmModel) Update

func (o *OrmModel) Update(i interface{}) *OrmModel

func (*OrmModel) Where

func (o *OrmModel) Where(cgs ...ConditionGroup) *OrmModel

func (*OrmModel) WherePK

func (o *OrmModel) WherePK() *OrmModel

WherePK WHERE 条件里使用主键进行查询 db:"xx,pk"

func (*OrmModel) With

func (o *OrmModel) With(t string) *OrmModel

func (*OrmModel) WithAsc

func (o *OrmModel) WithAsc(fields ...string) *OrmModel

func (*OrmModel) WithDesc

func (o *OrmModel) WithDesc(fields ...string) *OrmModel

Jump to

Keyboard shortcuts

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