db

package
v0.0.0-...-f1d2d96 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCustomType

func RegisterCustomType(t reflect.Type, fn CustomTypeFunc)

RegisterCustomType registers a custom type and its conversion function.

Types

type CustomTypeFunc

type CustomTypeFunc func(string) (reflect.Value, error)

CustomTypeFunc is a type for functions that convert a string to a custom type.

type MyDB

type MyDB struct {
	*sql.DB
}

myDB wraps a sql.DB connection pool.

func NewDB

func NewDB(dataSourceName string) (*MyDB, error)

NewDB initializes a new database connection.

func (*MyDB) Begin

func (db *MyDB) Begin() (*sql.Tx, error)

Begin starts a new database transaction.

func (*MyDB) BulkInsert

func (db *MyDB) BulkInsert(table string, data []map[string]interface{}) (sql.Result, error)

BulkInsert inserts multiple rows into the specified table.

func (*MyDB) BulkUpdate

func (db *MyDB) BulkUpdate(table string, data []map[string]interface{}, key string) error

BulkUpdate updates multiple rows in the specified table based on the key column.

func (*MyDB) Get

func (db *MyDB) Get(dest interface{}, query string, args ...interface{}) error

Get executes a query and scans the first row into the destination struct.

func (*MyDB) In

func (db *MyDB) In(query string, args ...interface{}) (string, []interface{}, error)

In expands slice arguments for SQL IN queries.

func (*MyDB) NamedExec

func (db *MyDB) NamedExec(query string, arg map[string]interface{}) (sql.Result, error)

NamedExec executes a named query with the provided arguments.

func (*MyDB) Select

func (db *MyDB) Select(dest interface{}, query string, args ...interface{}) error

Select executes a query and scans all rows into the destination slice.

Jump to

Keyboard shortcuts

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