Storage API
PolyglotDatabase Class
Dexie-based IndexedDB database implementation.
Schema Definition
this.version(1).stores({
chats: '++id, title, createdAt, updatedAt, lastModified, model, provider, currentModel, isArchived',
meta: 'id, lastSync, version'
});Tables
chats Table
Primary Key:
id(auto-increment string)Indexes:
title,createdAt,updatedAt,lastModified,model,provider,currentModel,isArchivedType:
Table<Chat, string>
meta Table
Primary Key:
id(string)Indexes:
lastSync,versionType:
Table<AppMeta, string>
Data Models
Chat Interface
Message Interface
AppMeta Interface
Internal Storage Operations
Date Conversion
convertDatesToObjects(chat: any): Chat
Converts stored date strings back to Date objects.
prepareChatForStorage(chat: Chat): Chat
Prepares chat object for IndexedDB storage with proper defaults.
Database Management
initialize(): Promise
Initialize database with schema validation and error recovery.
resetDatabase(): Promise
Delete and recreate database (used for error recovery).
Query Operations
Conversation Queries
Metadata Queries
Filtering Operations
Archive Filtering
Error Recovery
Schema Version Errors
Storage Quota Handling
Graceful degradation when quota exceeded
Automatic cleanup of oldest conversations
User notification of storage limitations
Network Errors
All operations work offline
Sync failures don't affect local operations
Automatic retry mechanisms for sync operations
Performance Characteristics
Query Performance
Primary key lookups: O(log n)
Index scans: O(log n + m) where m = result set size
Full table scans: O(n) - avoided where possible
Storage Efficiency
JSON serialization: Compact representation
Index overhead: ~10-15% storage overhead
Date storage: ISO strings for cross-browser compatibility
Memory Usage
Lazy loading: Conversations loaded on demand
Result caching: Dexie provides automatic result caching
Memory cleanup: Automatic garbage collection of unused objects
Browser Storage Limits
Typical Limits
Chrome: ~60% of available disk space
Firefox: Up to 2GB per origin
Safari: 1GB per origin
Edge: Similar to Chrome
Quota Management
Last updated