package store import "context" func (s *Store) CreateLibrary(ctx context.Context, name, root string) (int64, error) { var id int64 err := s.p.QueryRow(ctx, "INSERT INTO libraries (name, root_path) VALUES ($1,$2) RETURNING id", name, root).Scan(&id) return id, err } func (s *Store) ListLibraries(ctx context.Context) ([]Library, error) { rows, err := s.p.Query(ctx, "SELECT id, name, root_path, created_at FROM libraries ORDER BY id") if err != nil { return nil, err } defer rows.Close() var out []Library for rows.Next() { var l Library if err := rows.Scan(&l.ID, &l.Name, &l.RootPath, &l.CreatedAt); err != nil { return nil, err } out = append(out, l) } return out, rows.Err() } func (s *Store) GetLibrary(ctx context.Context, id int64) (Library, error) { var l Library err := s.p.QueryRow(ctx, "SELECT id, name, root_path, created_at FROM libraries WHERE id=$1", id). Scan(&l.ID, &l.Name, &l.RootPath, &l.CreatedAt) return l, err }