mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
Add tables, indexes, FTS5 virtual table, and triggers to support EPG (electronic program guide) data in the shared SQLite connection. The changes introduce epg_channels and epg_programs tables, multiple indexes for efficient lookups (by source, name, channel, start, and time range), and an epg_programs_fts virtual table with triggers to keep the full-text index synchronized with epg_programs. Register EPG database event handlers in the Electron backend and add an IPC handler for bulk-saving channels. The handler deletes existing channels for a source and inserts new channels in chunks to avoid large single inserts, returning the inserted count. These changes enable storing, querying, and full-text searching EPG data and prepare backend IPC endpoints for importing program guide data.
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