Skip to main content

electron/services/database/SettingsRepository

Repository for application settings persistence and management using the repository pattern.

Remarks

Handles CRUD operations for application configuration settings with type-safe value handling, validation, and atomic updates. Provides centralized settings management with proper transaction support and error handling.

Key features:

  • Type-safe settings CRUD operations with value conversion
  • Atomic setting updates with transaction support
  • Default value management and fallback handling
  • Efficient key-value storage with proper indexing
  • Comprehensive error handling with operational hooks
  • Setting validation and type coercion
  • Bulk operations for multiple settings updates

Examples

const settingsRepo = new SettingsRepository({ databaseService });

// Set a setting value
await settingsRepo.setSetting("historyLimit", 1000);

// Get a setting with default fallback
const limit = await settingsRepo.getSetting("historyLimit", 500);

// Get all settings
const allSettings = await settingsRepo.getAllSettings();
// Update multiple settings atomically
await settingsRepo.setSettings({
historyLimit: 1000,
checkInterval: 60000,
enableNotifications: true,
});

Classes

Interfaces