db

package
v0.0.0-...-4c2a98a Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateObject

func CreateObject(value interface{}) error

func GetDB

func GetDB() *gorm.DB

func InitConnDB

func InitConnDB(dbType string, dbConn string) error

func Ping

func Ping() error

func QueryRow

func QueryRow(sqlStr string) (*sql.Row, error)

QueryRow excute sql and return row

func QueryRows

func QueryRows(sqlStr string) (*sql.Rows, error)

func SearchObject

func SearchObject(objectPtr interface{}, wheres map[string]interface{}, out interface{}) error

func SearchObjectByIn

func SearchObjectByIn(objectPtr interface{}, wheres map[string]interface{},
	ins map[string]interface{}, out interface{}) error

func SearchObjectByOrder

func SearchObjectByOrder(objectPtr interface{}, wheres map[string]interface{}, ins map[string]interface{},
	orders string, limit, offset int, out interface{}) error

func SearchObjectPreload

func SearchObjectPreload(objectPtr interface{}, tableName string, wheres map[string]interface{},
	preloads []string, joins []string) error

note: return check gorm.ErrRecordNotFound

func SearchSelectPreload

func SearchSelectPreload(objectPtr interface{}, tableName, selectValue string,
	wheres map[string]interface{}, preloads []string, joins []string) error

note: return check gorm.ErrRecordNotFound

func SearchTableCount

func SearchTableCount(tableName, countField, wheres string) (int, error)

func SearchTableSum

func SearchTableSum(tableName, countField, wheres string) (float64, error)

func SetLogger

func SetLogger(logger *log.Logger)

SetLogger set log writer

func SetSQLMode

func SetSQLMode(enable bool)

SetSQLMode indicate whether log sql or not

func UpdateObject

func UpdateObject(objectPtr interface{}, wheres, updates map[string]interface{}) error

updates maybe use gorm.Expr()

func WriteError

func WriteError(sqlStr string, err error)

func WriteLog

func WriteLog(sqlStr string, args ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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