mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 04:31:27 +08:00
- Rename SessionLogEntity → SessionMessageEntity type definition - Rename SessionLogService → SessionMessageService with all methods - Rename API routes /logs → /messages for better REST semantics - Update database queries and service layer naming - Update all Swagger documentation and validation middleware - Maintain backward compatibility in database schema This improves code readability by using more accurate terminology for conversational message data rather than generic "log" naming.
53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
/**
|
|
* SQL queries for Session Message operations
|
|
*/
|
|
|
|
export const SessionMessageQueries = {
|
|
// CREATE
|
|
insert: `
|
|
INSERT INTO session_logs (session_id, parent_id, role, type, content, metadata, created_at, updated_at)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
`,
|
|
|
|
// READ
|
|
getById: `
|
|
SELECT * FROM session_logs
|
|
WHERE id = ?
|
|
`,
|
|
|
|
getBySessionId: `
|
|
SELECT * FROM session_logs
|
|
WHERE session_id = ?
|
|
ORDER BY created_at ASC, id ASC
|
|
`,
|
|
|
|
getBySessionIdWithPagination: `
|
|
SELECT * FROM session_logs
|
|
WHERE session_id = ?
|
|
ORDER BY created_at ASC, id ASC
|
|
LIMIT ? OFFSET ?
|
|
`,
|
|
|
|
getLatestBySessionId: `
|
|
SELECT * FROM session_logs
|
|
WHERE session_id = ?
|
|
ORDER BY created_at DESC, id DESC
|
|
LIMIT ?
|
|
`,
|
|
|
|
// UPDATE
|
|
update: `
|
|
UPDATE session_logs
|
|
SET content = ?, metadata = ?, updated_at = ?
|
|
WHERE id = ?
|
|
`,
|
|
|
|
// DELETE
|
|
deleteById: 'DELETE FROM session_logs WHERE id = ?',
|
|
|
|
deleteBySessionId: 'DELETE FROM session_logs WHERE session_id = ?',
|
|
|
|
// COUNT
|
|
countBySessionId: 'SELECT COUNT(*) as total FROM session_logs WHERE session_id = ?'
|
|
} as const
|