====== Smart Views ======
Smart Views are saved SQL queries that appear in your sidebar for quick access. They let you create custom filtered views of your file database.
===== What Are Smart Views? =====
A Smart View is a named SQL query with an optional icon that lives in the sidebar. Click it to run the query and see matching files instantly. Think of them as saved searches or bookmarks for your database.
===== Creating a Smart View =====
- Click **+** in the Smart Views section header
- Enter a **name** for the view (e.g., "Python Files", "Files Without Tags")
- Choose an **icon** from the emoji picker (40 options), or paste your own emoji
- Write a **SQL query** that returns file data
- Click **Save**
=== Example Queries ===
**All JavaScript files:**
SELECT * FROM files WHERE language = 'javascript'
**Files with the most relations:**
SELECT f.name, COUNT(r.id) as connections
FROM files f
LEFT JOIN relations r ON f.id = r.source_id OR f.id = r.target_id
GROUP BY f.id
ORDER BY connections DESC
LIMIT 20
**Recently modified files:**
SELECT * FROM files ORDER BY updated_at DESC LIMIT 10
**Files tagged as "todo":**
SELECT DISTINCT f.* FROM files f
JOIN tags t ON f.id = t.file_id
WHERE t.tag = 'todo'
**Orphan files (no relations):**
SELECT f.* FROM files f
WHERE f.id NOT IN (SELECT source_id FROM relations)
AND f.id NOT IN (SELECT target_id FROM relations)
===== Managing Smart Views =====
* **Run:** Click a Smart View in the sidebar to execute it
* **Edit:** Right-click and select **Edit** to modify the query, name, or icon
* **Delete:** Right-click and select **Delete**, or click the **x** button
* **Reorder:** Smart Views appear in the order they were created
===== Tips =====
**Tip:**
Smart Views run against the full SQLite database. You can join any tables (files, relations, tags, properties) to create powerful filtered views.