mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 09:26:14 -08:00
Three queries filter on categories.hidden = false: - getGlobalRecentlyAdded — every dashboard load (now sorts by added DESC on the indexed content side after the prior CAST removal) - searchContent — Xtream search with excludeHidden - globalSearch — global Xtream search with excludeHidden All three start from content and join into categories on the category_id PK. The hidden filter is then applied per-row, requiring a row lookup for every result candidate — even before LIMIT. Add a partial covering index on categories: idx_categories_visible(id, playlist_id, type) WHERE hidden = 0. Two wins: - Covering: SQLite serves the join (id) plus filters (playlist_id, type) and the hidden = 0 predicate directly from the index without ever touching the categories row. - Partial: hidden categories are absent from the index, so they're pruned before any work happens — no row lookup, no comparison. Schema mirrored in Drizzle so the ORM stays the single source of truth. CREATE INDEX IF NOT EXISTS so existing DBs pick it up on next startup with no migration needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Entire-Checkpoint: f957cd9849e0
Database
Shared database library for IPTVnator providing Drizzle ORM schema and connection utilities.
Usage
// Full access (electron-backend)
import { getDatabase, initDatabase } from 'database';
// Read-only access (agent-backend)
import { getReadOnlyDatabase } from 'database';
// Schema and types
import { content, categories, playlists, type Content } from 'database';
Exports
Schema (schema.ts)
- Tables:
playlists,categories,content,recentlyViewed,favorites - Types:
Playlist,Category,Content,RecentlyViewed,Favorite(andNew*variants)
Connection (connection.ts)
getDatabase(options?)- Full read-write accessgetReadOnlyDatabase()- Read-only access for agent queriesinitDatabase(options?)- Initialize with custom optionscloseDatabase()- Close connectiongetDatabasePath()- Get database file path
Database Location
The SQLite database is stored at: ~/.iptvnator/databases/iptvnator.db