boilerplate

package
v6.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is the error returned, if the entity is not found in the DB.
	ErrNotFound = errors.New("Not found")

	// ErrConflict is the error returned, if the adding or updating an entity
	// causes a conflict with an existing entity.
	ErrConflict = errors.New("Conflict")
)
View Source
var PreparedStmts = map[int]*sql.Stmt{}

PreparedStmts is a placeholder for transitioning to package-scoped transaction functions.

Functions

func PrepareStmts

func PrepareStmts(db preparer, skipErrors bool) (map[int]*sql.Stmt, error)

PrepareStmts prepares all registered statements and returns an index from statement code to prepared statement object.

func RegisterStmt

func RegisterStmt(sqlStmt string) int

RegisterStmt register a SQL statement.

Registered statements will be prepared upfront and reused, to speed up execution.

Return a unique registration code.

func Stmt

func Stmt(db dbtx, code int) (*sql.Stmt, error)

Stmt prepares the in-memory prepared statement for the transaction.

func StmtString

func StmtString(code int) (string, error)

StmtString returns the in-memory query string with the given code.

Types

type Marshaler

type Marshaler interface {
	MarshalDB() (string, error)
}

Marshaler is the interface that wraps the MarshalDB method, which converts the underlying type into a string representation suitable for persistence in the database.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalDB(string) error
}

Unmarshaler is the interface that wraps the UnmarshalDB method, which converts a string representation retrieved from the database into the underlying type.

Jump to

Keyboard shortcuts

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