queryable

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 2 Imported by: 0

README

sqlx-queryable

Build Status MIT license GoDoc

sqlx-queryable provides the Queryable interface which wraps sqlx.DB and sqlx.Tx methods. Requires Golang v1.18 or greater.

Install
go get github.com/alexandermac/sqlx-queryable
Usage
// `q` can be sqlx.DB or sqlx.Tx here
func getRecords(q Queryable) ([]Record, error) {
	var records []Record
	err := q.Select(&records, "SELECT * FROM records")
	if err != nil {
		panic(err)
	}

	return records, nil
}
License

Licensed under the MIT license.

Author

Alexander Mac

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queryable

type Queryable interface {
	Rebind(query string) string
	Select(dest any, query string, args ...any) error
	Get(dest any, query string, args ...any) error
	Exec(query string, args ...any) (sql.Result, error)
	NamedExec(query string, arg any) (sql.Result, error)
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
}

Jump to

Keyboard shortcuts

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