orm

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows = errs.ErrNoRows
)

Functions

This section is empty.

Types

type Aggregate added in v0.1.25

type Aggregate struct {
	Fn    string
	Arg   string
	Alias string
}

Aggregate 聚合函数

func Avg added in v0.1.25

func Avg(col string) Aggregate

func (Aggregate) As added in v0.1.25

func (a Aggregate) As(alias string) Aggregate

func (Aggregate) Select added in v0.1.25

func (a Aggregate) Select()

type Assignable added in v0.1.25

type Assignable interface {
	Assign()
}

Assignable 可用于update语句的SET,ON DUPLICATE KEY UPDATE后

type Assignment added in v0.1.25

type Assignment struct {
	Column string
	Val    any
}

func Assign added in v0.1.25

func Assign(col string, val any) Assignment

func (Assignment) Assign added in v0.1.25

func (Assignment) Assign()

type Column

type Column struct {
	Name  string
	Alias string // 别名
}

func C

func C(columnName string) Column

func (Column) As added in v0.1.25

func (c Column) As(alias string) Column

func (Column) Assign added in v0.1.25

func (Column) Assign()

func (Column) Eq

func (c Column) Eq(val any) Predicate

func (Column) LT added in v0.1.24

func (c Column) LT(val any) Predicate

func (Column) Plus added in v0.1.25

func (c Column) Plus(val any) Predicate

func (Column) Select added in v0.1.25

func (c Column) Select()

type DB

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

func MustNewDB

func MustNewDB(driveName string, dataSourceName string, opts ...DBOption) *DB

func Open added in v0.1.24

func Open(driveName string, dataSourceName string, opts ...DBOption) (*DB, error)

func OpenDB added in v0.1.24

func OpenDB(sqlDB *sql.DB, opts ...DBOption) (*DB, error)

type DBOption

type DBOption func(db *DB)

func DBWithCreator added in v0.1.24

func DBWithCreator(creator valuer.Creator) DBOption

func DBWithDialect added in v0.1.25

func DBWithDialect(dialect Dialect) DBOption

func DBWithRegister

func DBWithRegister(r *schema.Register) DBOption

type Deleter

type Deleter[T any] struct {
	// contains filtered or unexported fields
}

func NewDeleter

func NewDeleter[T any](db *DB) *Deleter[T]

func (*Deleter[T]) Build

func (d *Deleter[T]) Build() (*Query, error)

func (*Deleter[T]) Exec

func (d *Deleter[T]) Exec(ctx context.Context) (sql.Result, error)

func (*Deleter[T]) From

func (d *Deleter[T]) From(tableName string) *Deleter[T]

func (*Deleter) Quoter added in v0.1.25

func (b *Deleter) Quoter(columnName string)

func (*Deleter[T]) Where

func (d *Deleter[T]) Where(e Predicate) *Deleter[T]

type Dialect added in v0.1.25

type Dialect interface {
	// 表名,列名标记符号 mysql `
	Quoter() string

	BuildOnDuplicateKey(b *builder, odk *OnDuplicateKey) error
}

type Executor

type Executor interface {
	Exec(ctx context.Context) Result
}

type Expression

type Expression interface {
	// contains filtered or unexported methods
}

type Inserter added in v0.1.25

type Inserter[T any] struct {
	// contains filtered or unexported fields
}

func NewInserter added in v0.1.25

func NewInserter[T any](db *DB) *Inserter[T]

func (*Inserter[T]) Build added in v0.1.25

func (i *Inserter[T]) Build() (*Query, error)

func (*Inserter[T]) Columns added in v0.1.25

func (i *Inserter[T]) Columns(columns ...string) *Inserter[T]

Columns 指定要插入的列

func (*Inserter[T]) Exec added in v0.1.25

func (i *Inserter[T]) Exec(ctx context.Context) Result

func (*Inserter[T]) OnDuplicateKey added in v0.1.25

func (i *Inserter[T]) OnDuplicateKey() *OnDuplicateKeyBuilder[T]

OnDuplicateKey 主键冲突时的操作

func (*Inserter) Quoter added in v0.1.25

func (b *Inserter) Quoter(columnName string)

func (*Inserter[T]) Values added in v0.1.25

func (i *Inserter[T]) Values(values ...*T) *Inserter[T]

type OnDuplicateKey added in v0.1.25

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

type OnDuplicateKeyBuilder added in v0.1.25

type OnDuplicateKeyBuilder[T any] struct {
	// contains filtered or unexported fields
}

func (*OnDuplicateKeyBuilder[T]) Update added in v0.1.25

func (b *OnDuplicateKeyBuilder[T]) Update(assigns ...Assignable) *Inserter[T]

type Predicate

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

func Not

func Not(right Predicate) Predicate

func (Predicate) And

func (left Predicate) And(right Predicate) Predicate

func (Predicate) Or

func (left Predicate) Or(right Predicate) Predicate

type Querier

type Querier[T any] interface {
	Get(ctx context.Context) (*T, error)
	GetMulti(ctx context.Context) ([]*T, error)
}

Querier querier 用于select语句

type Query

type Query struct {
	SQL  string
	Args []any
}

type QueryBuilder

type QueryBuilder interface {
	Build() (*Query, error)
}

type RawExpression added in v0.1.25

type RawExpression struct {
	Expr string
	Args []any
}

RawExpression raw expression will not do anything to this

func Raw added in v0.1.25

func Raw(expr string, args ...any) RawExpression

func (RawExpression) AsPredicate added in v0.1.25

func (r RawExpression) AsPredicate() Predicate

func (RawExpression) Select added in v0.1.25

func (r RawExpression) Select()

type Result added in v0.1.25

type Result struct {
	Res sql.Result
	Err error
}

func (Result) LastInsertId added in v0.1.25

func (r Result) LastInsertId() (int64, error)

func (Result) RowsAffected added in v0.1.25

func (r Result) RowsAffected() (int64, error)

type Selectable added in v0.1.25

type Selectable interface {
	Select()
}

type Selector

type Selector[T any] struct {
	// contains filtered or unexported fields
}

func NewSelector

func NewSelector[T any](db *DB) *Selector[T]

func (*Selector[T]) Build

func (s *Selector[T]) Build() (*Query, error)

func (*Selector[T]) From

func (s *Selector[T]) From(tableName string) *Selector[T]

func (*Selector[T]) Get

func (s *Selector[T]) Get(ctx context.Context) (*T, error)

func (*Selector[T]) GetMulti

func (s *Selector[T]) GetMulti(ctx context.Context) ([]*T, error)

func (*Selector[T]) GroupBy added in v0.1.25

func (s *Selector[T]) GroupBy(groupBy ...Expression) *Selector[T]

func (*Selector) Quoter added in v0.1.25

func (b *Selector) Quoter(columnName string)

func (*Selector[T]) Select added in v0.1.25

func (s *Selector[T]) Select(cols ...Selectable) *Selector[T]

func (*Selector[T]) Where

func (s *Selector[T]) Where(e Predicate) *Selector[T]

type StandSQL added in v0.1.25

type StandSQL struct{}

func (StandSQL) BuildOnDuplicateKey added in v0.1.25

func (s StandSQL) BuildOnDuplicateKey(b *builder, odk *OnDuplicateKey) error

func (StandSQL) Quoter added in v0.1.25

func (s StandSQL) Quoter() string

Directories

Path Synopsis
internal
元数据注册中心
元数据注册中心
until

Jump to

Keyboard shortcuts

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