Categorygithub.com/alexandermac/sqlx-queryable
modulepackage
0.2.0
Repository: https://github.com/alexandermac/sqlx-queryable.git
Documentation: pkg.go.dev

# README

sqlx-queryable

Build Status MIT license GoDoc

sqlx-queryable provides the Queryable interface which wraps identical sqlx.DB and sqlx.Tx methods. The interface can be used when a function performs a database query directly or under a transaction. Requires Golang v1.18 or greater.

Install

go get github.com/alexandermac/sqlx-queryable

Usage

import queryable "github.com/alexandermac/sqlx-queryable"

// `q` can be sqlx.DB or sqlx.Tx
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

# Interfaces

No description provided by the author