db

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExcludedFieldName = "Table"
	TableName         = "TableName"
	ModelTagKeyName   = "db"
	TagNameForTable   = "name"
)

Variables

This section is empty.

Functions

func FetchAll

func FetchAll[M iTable](pool *ConnPool, whereOrQueryStmt string, args ...any) (collection.Slice[M], error)

FetchAll 支持查询多条数据

func FetchOne

func FetchOne[M iTable](pool *ConnPool, whereOrQueryStmt string, args ...any) (M, error)

FetchOne 查询单条数据

Types

type Column added in v1.1.0

type Column struct {
	Name       string      `json:"name"`
	Type       string      `json:"type"`
	IsNullable int         `json:"isNullable"`
	Default    interface{} `json:"default"`
	Extra      string      `json:"extra"`
}

type Columns added in v1.1.0

type Columns struct {
	Cols []Column
}

func (Columns) Compare added in v1.1.0

func (c Columns) Compare(exists ...string) (mustAdd, recommendedAdd []Column, mustDel []string)

type ConnPool

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

func OpenPool

func OpenPool(connStr string, params ...int) (pool *ConnPool, err error)

func (*ConnPool) Close

func (pool *ConnPool) Close() error

func (*ConnPool) Count added in v1.0.5

func (pool *ConnPool) Count(sqlStmt string) int

func (*ConnPool) Exec

func (pool *ConnPool) Exec(query string, args ...any) (n int64, err error)

Exec 支持数据库增/删/改

func (*ConnPool) GetColumns added in v1.1.0

func (pool *ConnPool) GetColumns(schema, table string) (Columns, error)

type Table

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

func (Table) IsDataNotNull

func (t Table) IsDataNotNull() bool

Jump to

Keyboard shortcuts

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