golang-template/internal/database/sqlc/sessions.sql.go

61 lines
1.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: sessions.sql
package sqlc
import (
"context"
)
const deleteSessionById = `-- name: DeleteSessionById :exec
DELETE FROM user_session WHERE id = $1
`
func (q *Queries) DeleteSessionById(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, deleteSessionById, id)
return err
}
const insertSession = `-- name: InsertSession :one
INSERT INTO user_session (id, secret_hash, user_id)
VALUES ($1, $2, $3)
RETURNING id, secret_hash, user_id, created_at
`
type InsertSessionParams struct {
ID string
SecretHash []byte
UserID string
}
func (q *Queries) InsertSession(ctx context.Context, arg InsertSessionParams) (UserSession, error) {
row := q.db.QueryRowContext(ctx, insertSession, arg.ID, arg.SecretHash, arg.UserID)
var i UserSession
err := row.Scan(
&i.ID,
&i.SecretHash,
&i.UserID,
&i.CreatedAt,
)
return i, err
}
const selectSessionById = `-- name: SelectSessionById :one
SELECT id, secret_hash, user_id, created_at
FROM user_session
WHERE id = $1
`
func (q *Queries) SelectSessionById(ctx context.Context, id string) (UserSession, error) {
row := q.db.QueryRowContext(ctx, selectSessionById, id)
var i UserSession
err := row.Scan(
&i.ID,
&i.SecretHash,
&i.UserID,
&i.CreatedAt,
)
return i, err
}