db

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB simple wrapper of Gorm

func NewDB

func NewDB(debug bool, dsn string) (*DB, error)

NewDB return a new DB instance

func NewDBWithMockForTest

func NewDBWithMockForTest(debug bool, conn *sql.DB) (*DB, error)

NewDBWithMockForTest return a new DB instance JUST FOR TESTS JUST FOR TESTS JUST FOR TESTS

func (*DB) BlockLogger added in v0.0.8

func (db *DB) BlockLogger()

func (*DB) Exec added in v0.0.8

func (db *DB) Exec(sql string, args ...interface{}) error

Exec 执行 insert、update、delete 等操作

func (*DB) GetDriver

func (db *DB) GetDriver() *gorm.DB

func (*DB) QueryMore

func (db *DB) QueryMore(sql string, args ...interface{}) (*sql.Rows, error)

QueryMore 查询多个结果,返回的结果需要配合 ScanRows 使用 example: rows, _ := db.QueryMore("SELECT * FROM table LIMIT 10")

for rows.Next(){
   _ =  db.ScanRows(rows, &dest)
}

func (*DB) QueryOne

func (db *DB) QueryOne(dest interface{}, sql string, args ...interface{}) error

QueryOne

func (*DB) ScanRows

func (db *DB) ScanRows(rows *sql.Rows, dest interface{}) error

ScanRows 扫描 rows 到 dest

Jump to

Keyboard shortcuts

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