mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-24 12:41:56 +08:00
- 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. |
||
|---|---|---|
| .. | ||
| api | ||
| db | ||
| migration/v2 | ||
| services | ||
| CacheService.ts | ||
| DataApiService.ts | ||
| PreferenceService.ts | ||
| README.md | ||
Main Data Layer
This directory contains the main process data management implementation.
Documentation
- Overview: docs/en/references/data/README.md
- DataApi in Main: data-api-in-main.md
- Database Patterns: database-patterns.md
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
- Define schema in
@shared/data/api/schemas/ - Implement handler in
api/handlers/ - Create business service in
services/ - Create repository in
repositories/(if complex domain)
Database Commands
# Generate migrations
yarn db:migrations:generate