Files
iptvnator/libs/shared/database/README.md
T
4gray 815279f49f feat(db): add shared database library with sql config
Introduce a shared database schema library for Drizzle ORM and
configure its TypeScript build settings. Move the canonical schema
into libs/shared/database/src/lib/schema.ts and expose strong
typing and table definitions for playlists, categories, content,
recently_viewed and favorites. Add tsconfig.lib.json to set
outDir, declaration output and node types for the shared lib.

Keep apps/electron-backend compatibility by re-exporting the
schema and types from the new shared library (apps/electron-backend
now imports the shared definitions rather than duplicating them).

These changes centralize the database schema as a single source
of truth, prevent duplication, and enable read-only consumers
(e.g. agent-backend) to depend on compiled type declarations.
2025-12-26 00:35:07 +01:00

34 lines
1009 B
Markdown

# Database
Shared database library for IPTVnator providing Drizzle ORM schema and connection utilities.
## Usage
```typescript
// 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` (and `New*` variants)
### Connection (`connection.ts`)
- `getDatabase(options?)` - Full read-write access
- `getReadOnlyDatabase()` - Read-only access for agent queries
- `initDatabase(options?)` - Initialize with custom options
- `closeDatabase()` - Close connection
- `getDatabasePath()` - Get database file path
## Database Location
The SQLite database is stored at: `~/.iptvnator/databases/iptvnator.db`