Documentation
¶
Index ¶
Constants ¶
View Source
const POSTGRES = "postgres"
The driver strings must match the driver from the stdlib
View Source
const SQLITE3 = "sqlite3"
Variables ¶
View Source
var ErrMismatchedRowsAffected error = errors.New("Mismatched rows affected")
View Source
var ErrQueryReturnedZeroRows error = errors.New("Query returned 0 rows")
Functions ¶
func Scan ¶
Scan reads data from the given rows into the target.
*int64, *string, etc: First column of first row *struct: First row []int64, []*int64, []string, []*string: First column, all rows []struct, []*struct: All columns, all rows
The mapping into structs is done by analyzing the struct's tag names and using the given "db" key for the mapping. The mapping works on exported fields only. Use "-" as mapping name to ignore the field.
Types ¶
type DB ¶
type DB interface {
Query
Exec
Begin() (TX, error)
BeginRead() (TX, error)
BeginContext(context.Context, *sql.TxOptions) (TX, error)
Close() error
IsClosed() bool
Name() (string, error)
DB() *sql.DB
Log() DB
Version() (string, error)
ExecTX(context.Context, func(context.Context) error, *sql.TxOptions) error
}
type DebugLevel ¶
type DebugLevel int
const ( PANIC DebugLevel = 1 ERROR DebugLevel = 2 UPDATE DebugLevel = 4 INSERT DebugLevel = 8 EXEC DebugLevel = 16 QUERY DebugLevel = 32 QUERY_DUMP DebugLevel = 64 )
type Exec ¶
type Exec interface {
Query
ExecContext(context.Context, string, ...any) error
Exec(string, ...any) error
ExecContextRowsAffected(context.Context, string, ...any) (int64, int64, error)
Insert(string, any) error
InsertBulk(string, any) error
InsertBulkContext(context.Context, string, any) error
InsertBulkOnConflictDoNothingContext(context.Context, string, any, ...string) error
InsertContext(context.Context, string, any) error
Save(string, any) error
Update(string, any) error
UpdateContext(context.Context, string, any) error
UpdateBulkContext(context.Context, string, any) error
}
type NullRawMessage ¶
type NullRawMessage struct {
Data json.RawMessage
Valid bool
}
func (*NullRawMessage) Scan ¶
func (nj *NullRawMessage) Scan(value interface{}) error
type PlaceholderMode ¶
type PlaceholderMode int
const ( DOLLAR PlaceholderMode = 1 QUESTION PlaceholderMode = 2 )
type Query ¶
type Query interface {
ExecContext(context.Context, string, ...any) error
Exec(string, ...any) error
ExecContextRowsAffected(context.Context, string, ...any) (int64, int64, error)
Insert(string, any) error
InsertBulk(string, any) error
InsertBulkContext(context.Context, string, any) error
InsertBulkOnConflictDoNothingContext(context.Context, string, any, ...string) error
InsertContext(context.Context, string, any) error
Save(string, any) error
Update(string, any) error
UpdateContext(context.Context, string, any) error
UpdateBulkContext(context.Context, string, any) error
QueryContext(context.Context, any, string, ...any) error
Query(any, string, ...any) error
Driver() dbDriver
EscValue(string) string
}
Click to show internal directories.
Click to hide internal directories.