| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- // Code generated by sqlc. DO NOT EDIT.
- // versions:
- // sqlc v1.30.0
- // source: read_files.sql
- package db
- import (
- "context"
- )
- const getFileRead = `-- name: GetFileRead :one
- SELECT session_id, path, read_at FROM read_files
- WHERE session_id = ? AND path = ? LIMIT 1
- `
- type GetFileReadParams struct {
- SessionID string `json:"session_id"`
- Path string `json:"path"`
- }
- func (q *Queries) GetFileRead(ctx context.Context, arg GetFileReadParams) (ReadFile, error) {
- row := q.queryRow(ctx, q.getFileReadStmt, getFileRead, arg.SessionID, arg.Path)
- var i ReadFile
- err := row.Scan(&i.SessionID, &i.Path, &i.ReadAt)
- return i, err
- }
- const listSessionReadFiles = `-- name: ListSessionReadFiles :many
- SELECT session_id, path, read_at FROM read_files
- WHERE session_id = ?
- ORDER BY read_at DESC
- `
- func (q *Queries) ListSessionReadFiles(ctx context.Context, sessionID string) ([]ReadFile, error) {
- rows, err := q.query(ctx, q.listSessionReadFilesStmt, listSessionReadFiles, sessionID)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- items := []ReadFile{}
- for rows.Next() {
- var i ReadFile
- if err := rows.Scan(&i.SessionID, &i.Path, &i.ReadAt); err != nil {
- return nil, err
- }
- items = append(items, i)
- }
- if err := rows.Close(); err != nil {
- return nil, err
- }
- if err := rows.Err(); err != nil {
- return nil, err
- }
- return items, nil
- }
- const recordFileRead = `-- name: RecordFileRead :exec
- INSERT INTO read_files (
- session_id,
- path,
- read_at
- ) VALUES (
- ?,
- ?,
- strftime('%s', 'now')
- ) ON CONFLICT(path, session_id) DO UPDATE SET
- read_at = excluded.read_at
- `
- type RecordFileReadParams struct {
- SessionID string `json:"session_id"`
- Path string `json:"path"`
- }
- func (q *Queries) RecordFileRead(ctx context.Context, arg RecordFileReadParams) error {
- _, err := q.exec(ctx, q.recordFileReadStmt, recordFileRead, arg.SessionID, arg.Path)
- return err
- }
|