orm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoTransaction

func AutoTransaction(trans func(db IDBHandle) error) error

func Binds

func Binds[T ITable](m T) []interface{}

Types

type IDBHandle

type IDBHandle IExecutor

IDBHandle Deprecated, please use `IExecutor` instead

type IExecutor

type IExecutor interface {
	QueryRow(query string, args ...any) *sql.Row
	Query(query string, args ...any) (*sql.Rows, error)
	Prepare(query string) (*sql.Stmt, error)
	Exec(query string, args ...any) (sql.Result, error)
}

type ITable

type ITable interface {
	TableName() string
	Pk() string
}

type ORM

type ORM[T ITable] struct {
	Record T
	// contains filtered or unexported fields
}

func New

func New[T ITable](data T) *ORM[T]

func (*ORM[T]) Count

func (c *ORM[T]) Count(where string, values []interface{}) (int64, error)

func (*ORM[T]) Delete

func (c *ORM[T]) Delete(pk int64) (int64, error)

func (*ORM[T]) Fields

func (c *ORM[T]) Fields() string

func (*ORM[T]) Limit

func (c *ORM[T]) Limit(where string, values []interface{}, offset, size int64, order string) ([]T, error)

func (*ORM[T]) Pk

func (c *ORM[T]) Pk() string

func (*ORM[T]) Row

func (c *ORM[T]) Row(where string, values []interface{}) (T, error)

func (*ORM[T]) Rows

func (c *ORM[T]) Rows(where string, values []interface{}) ([]T, error)

func (*ORM[T]) Save

func (c *ORM[T]) Save() (int64, error)

func (*ORM[T]) Saves

func (c *ORM[T]) Saves(rows []T) (int64, error)

func (*ORM[T]) SetRDb

func (c *ORM[T]) SetRDb(rdb IDBHandle) *ORM[T]

func (*ORM[T]) SetWDb

func (c *ORM[T]) SetWDb(wdb IDBHandle) *ORM[T]

func (*ORM[T]) Sum

func (c *ORM[T]) Sum(col, where string, values []interface{}) (int64, error)

func (*ORM[T]) TableName

func (c *ORM[T]) TableName() string

func (*ORM[T]) Update

func (c *ORM[T]) Update(pk int64) (int64, error)

func (*ORM[T]) UpdateByPk

func (c *ORM[T]) UpdateByPk(data map[string]interface{}, pk int64) (int64, error)

Jump to

Keyboard shortcuts

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