https://github.com/alexandermac/sqlx-queryable
Provides the Queryable interface for identical sqlx.DB and sqlx.Tx methods.
https://github.com/alexandermac/sqlx-queryable
Last synced: 5 months ago
JSON representation
Provides the Queryable interface for identical sqlx.DB and sqlx.Tx methods.
- Host: GitHub
- URL: https://github.com/alexandermac/sqlx-queryable
- Owner: AlexanderMac
- License: mit
- Created: 2023-09-15T16:04:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-29T18:19:19.000Z (over 2 years ago)
- Last Synced: 2023-09-29T23:11:35.308Z (over 2 years ago)
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sqlx-queryable
Provides an interface for identical sqlx.DB and sqlx.Tx methods.
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
```sh
go get github.com/alexandermac/sqlx-queryable
```
### Usage
```go
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