Begin migration to sqlc

This commit is contained in:
2021-11-08 21:32:30 +00:00
parent f019c47d21
commit cf1bc70103
17 changed files with 427 additions and 72 deletions

View File

@ -1,14 +1,30 @@
package postgres
import "gopkg.in/pg.v5"
// Connect to a database
func Connect(server string, user string, password string, database string) *pg.DB {
db := pg.Connect(&pg.Options{
User: user,
Password: password,
Addr: server,
Database: database,
})
return db
}
// Code generated by sqlc. DO NOT EDIT.
package postgres
import (
"context"
"github.com/jackc/pgconn"
"github.com/jackc/pgx/v4"
)
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
return &Queries{
db: tx,
}
}