197 lines
6.2 KiB
Go
197 lines
6.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
type DBTX interface {
|
|
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
|
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
|
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
|
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
|
}
|
|
|
|
func New(db DBTX) *Queries {
|
|
return &Queries{db: db}
|
|
}
|
|
|
|
func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
|
|
q := Queries{db: db}
|
|
var err error
|
|
if q.authUserStmt, err = db.PrepareContext(ctx, authUser); err != nil {
|
|
return nil, fmt.Errorf("error preparing query AuthUser: %w", err)
|
|
}
|
|
if q.createEntryStmt, err = db.PrepareContext(ctx, createEntry); err != nil {
|
|
return nil, fmt.Errorf("error preparing query CreateEntry: %w", err)
|
|
}
|
|
if q.createUserStmt, err = db.PrepareContext(ctx, createUser); err != nil {
|
|
return nil, fmt.Errorf("error preparing query CreateUser: %w", err)
|
|
}
|
|
if q.deleteEntryStmt, err = db.PrepareContext(ctx, deleteEntry); err != nil {
|
|
return nil, fmt.Errorf("error preparing query DeleteEntry: %w", err)
|
|
}
|
|
if q.deleteUserStmt, err = db.PrepareContext(ctx, deleteUser); err != nil {
|
|
return nil, fmt.Errorf("error preparing query DeleteUser: %w", err)
|
|
}
|
|
if q.entriesByTokenStmt, err = db.PrepareContext(ctx, entriesByToken); err != nil {
|
|
return nil, fmt.Errorf("error preparing query EntriesByToken: %w", err)
|
|
}
|
|
if q.getEntriesStmt, err = db.PrepareContext(ctx, getEntries); err != nil {
|
|
return nil, fmt.Errorf("error preparing query GetEntries: %w", err)
|
|
}
|
|
if q.getEntryStmt, err = db.PrepareContext(ctx, getEntry); err != nil {
|
|
return nil, fmt.Errorf("error preparing query GetEntry: %w", err)
|
|
}
|
|
if q.getUserStmt, err = db.PrepareContext(ctx, getUser); err != nil {
|
|
return nil, fmt.Errorf("error preparing query GetUser: %w", err)
|
|
}
|
|
if q.getUserByTokenStmt, err = db.PrepareContext(ctx, getUserByToken); err != nil {
|
|
return nil, fmt.Errorf("error preparing query GetUserByToken: %w", err)
|
|
}
|
|
if q.similarEntriesStmt, err = db.PrepareContext(ctx, similarEntries); err != nil {
|
|
return nil, fmt.Errorf("error preparing query SimilarEntries: %w", err)
|
|
}
|
|
if q.validTokenStmt, err = db.PrepareContext(ctx, validToken); err != nil {
|
|
return nil, fmt.Errorf("error preparing query ValidToken: %w", err)
|
|
}
|
|
return &q, nil
|
|
}
|
|
|
|
func (q *Queries) Close() error {
|
|
var err error
|
|
if q.authUserStmt != nil {
|
|
if cerr := q.authUserStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing authUserStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.createEntryStmt != nil {
|
|
if cerr := q.createEntryStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing createEntryStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.createUserStmt != nil {
|
|
if cerr := q.createUserStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing createUserStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.deleteEntryStmt != nil {
|
|
if cerr := q.deleteEntryStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing deleteEntryStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.deleteUserStmt != nil {
|
|
if cerr := q.deleteUserStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing deleteUserStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.entriesByTokenStmt != nil {
|
|
if cerr := q.entriesByTokenStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing entriesByTokenStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.getEntriesStmt != nil {
|
|
if cerr := q.getEntriesStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing getEntriesStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.getEntryStmt != nil {
|
|
if cerr := q.getEntryStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing getEntryStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.getUserStmt != nil {
|
|
if cerr := q.getUserStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing getUserStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.getUserByTokenStmt != nil {
|
|
if cerr := q.getUserByTokenStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing getUserByTokenStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.similarEntriesStmt != nil {
|
|
if cerr := q.similarEntriesStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing similarEntriesStmt: %w", cerr)
|
|
}
|
|
}
|
|
if q.validTokenStmt != nil {
|
|
if cerr := q.validTokenStmt.Close(); cerr != nil {
|
|
err = fmt.Errorf("error closing validTokenStmt: %w", cerr)
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
|
|
switch {
|
|
case stmt != nil && q.tx != nil:
|
|
return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
|
|
case stmt != nil:
|
|
return stmt.ExecContext(ctx, args...)
|
|
default:
|
|
return q.db.ExecContext(ctx, query, args...)
|
|
}
|
|
}
|
|
|
|
func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
|
|
switch {
|
|
case stmt != nil && q.tx != nil:
|
|
return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
|
|
case stmt != nil:
|
|
return stmt.QueryContext(ctx, args...)
|
|
default:
|
|
return q.db.QueryContext(ctx, query, args...)
|
|
}
|
|
}
|
|
|
|
func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
|
|
switch {
|
|
case stmt != nil && q.tx != nil:
|
|
return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
|
|
case stmt != nil:
|
|
return stmt.QueryRowContext(ctx, args...)
|
|
default:
|
|
return q.db.QueryRowContext(ctx, query, args...)
|
|
}
|
|
}
|
|
|
|
type Queries struct {
|
|
db DBTX
|
|
tx *sql.Tx
|
|
authUserStmt *sql.Stmt
|
|
createEntryStmt *sql.Stmt
|
|
createUserStmt *sql.Stmt
|
|
deleteEntryStmt *sql.Stmt
|
|
deleteUserStmt *sql.Stmt
|
|
entriesByTokenStmt *sql.Stmt
|
|
getEntriesStmt *sql.Stmt
|
|
getEntryStmt *sql.Stmt
|
|
getUserStmt *sql.Stmt
|
|
getUserByTokenStmt *sql.Stmt
|
|
similarEntriesStmt *sql.Stmt
|
|
validTokenStmt *sql.Stmt
|
|
}
|
|
|
|
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
|
return &Queries{
|
|
db: tx,
|
|
tx: tx,
|
|
authUserStmt: q.authUserStmt,
|
|
createEntryStmt: q.createEntryStmt,
|
|
createUserStmt: q.createUserStmt,
|
|
deleteEntryStmt: q.deleteEntryStmt,
|
|
deleteUserStmt: q.deleteUserStmt,
|
|
entriesByTokenStmt: q.entriesByTokenStmt,
|
|
getEntriesStmt: q.getEntriesStmt,
|
|
getEntryStmt: q.getEntryStmt,
|
|
getUserStmt: q.getUserStmt,
|
|
getUserByTokenStmt: q.getUserByTokenStmt,
|
|
similarEntriesStmt: q.similarEntriesStmt,
|
|
validTokenStmt: q.validTokenStmt,
|
|
}
|
|
}
|