feat: add generated query

This commit is contained in:
Vinicius Souza 2024-08-09 11:44:15 +00:00
parent b6819e8205
commit 034be9f4ae
3 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,32 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
package pgstore
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
)
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,
}
}

View file

@ -0,0 +1,22 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
package pgstore
import (
"github.com/google/uuid"
)
type Message struct {
ID uuid.UUID
RoomID uuid.UUID
Message string
ReactionCount int64
Answered bool
}
type Room struct {
ID uuid.UUID
Theme string
}

View file

@ -0,0 +1,26 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.27.0
// source: queries.sql
package pgstore
import (
"context"
"github.com/google/uuid"
)
const getRoom = `-- name: GetRoom :one
SELECT
"id", "theme"
FROM rooms
WHERE id = $1
`
func (q *Queries) GetRoom(ctx context.Context, id uuid.UUID) (Room, error) {
row := q.db.QueryRow(ctx, getRoom, id)
var i Room
err := row.Scan(&i.ID, &i.Theme)
return i, err
}