[very crude, wip] post to bsky without the distraction of feeds
1// Code generated by sqlc. DO NOT EDIT.
2// versions:
3// sqlc v1.30.0
4// source: visitors.sql
5
6package dbgen
7
8import (
9 "context"
10 "time"
11)
12
13const upsertVisitor = `-- name: UpsertVisitor :exec
14INSERT INTO
15 visitors (id, view_count, created_at, last_seen)
16VALUES
17 (?, 1, ?, ?) ON CONFLICT (id) DO
18UPDATE
19SET
20 view_count = view_count + 1,
21 last_seen = excluded.last_seen
22`
23
24type UpsertVisitorParams struct {
25 ID string `json:"id"`
26 CreatedAt time.Time `json:"created_at"`
27 LastSeen time.Time `json:"last_seen"`
28}
29
30func (q *Queries) UpsertVisitor(ctx context.Context, arg UpsertVisitorParams) error {
31 _, err := q.db.ExecContext(ctx, upsertVisitor, arg.ID, arg.CreatedAt, arg.LastSeen)
32 return err
33}
34
35const visitorWithID = `-- name: VisitorWithID :one
36SELECT
37 id, view_count, created_at, last_seen
38FROM
39 visitors
40WHERE
41 id = ?
42`
43
44func (q *Queries) VisitorWithID(ctx context.Context, id string) (Visitor, error) {
45 row := q.db.QueryRowContext(ctx, visitorWithID, id)
46 var i Visitor
47 err := row.Scan(
48 &i.ID,
49 &i.ViewCount,
50 &i.CreatedAt,
51 &i.LastSeen,
52 )
53 return i, err
54}