cherry-studio/src/main/data
fullex 096259cf27 refactor(MessageService): enhance rowToMessage function to handle JSON parsing
- Updated rowToMessage to include a parseJson utility for handling both parsed objects and JSON strings from raw SQL queries.
- Ensured that data fields such as data, assistantMeta, modelMeta, and stats are correctly parsed when necessary.
- Added documentation to clarify the handling of JSON columns in Drizzle ORM.
2026-01-05 18:59:00 +08:00
..
api feat: enhance cursor-based pagination in API documentation and types 2026-01-04 22:31:15 +08:00
db feat: add custom SQL handling for triggers and virtual tables 2026-01-04 01:07:04 +08:00
migration/v2 refactor(migration): improve ChatMigrator's handling of duplicate messages and active node selection 2026-01-01 23:26:28 +08:00
services refactor(MessageService): enhance rowToMessage function to handle JSON parsing 2026-01-05 18:59:00 +08:00
CacheService.ts feat(cache): enhance shared cache functionality and synchronization in main 2025-12-29 23:56:27 +08:00
DataApiService.ts feat: enhance CacheService and DataApiService documentation and structure 2025-11-01 18:36:28 +08:00
PreferenceService.ts refactor(preferences): rename and update multiple preferences result type 2025-12-02 15:09:32 +08:00
README.md docs(data): update README and remove outdated API design guidelines 2025-12-29 17:15:06 +08:00

Main Data Layer

This directory contains the main process data management implementation.

Documentation

Directory Structure

src/main/data/
├── api/                       # Data API framework
│   ├── core/                  # ApiServer, MiddlewareEngine, adapters
│   └── handlers/              # API endpoint implementations
├── services/                  # Business logic layer
├── repositories/              # Data access layer (selective usage)
├── db/                        # Database layer
│   ├── schemas/               # Drizzle table definitions
│   ├── seeding/               # Database initialization
│   └── DbService.ts           # Database connection management
├── migration/                 # Data migration system
├── CacheService.ts            # Cache management
├── DataApiService.ts          # API coordination
└── PreferenceService.ts       # User preferences

Quick Reference

Adding New API Endpoints

  1. Define schema in @shared/data/api/schemas/
  2. Implement handler in api/handlers/
  3. Create business service in services/
  4. Create repository in repositories/ (if complex domain)

Database Commands

# Generate migrations
yarn db:migrations:generate