Add database for library

This commit is contained in:
Myx
2025-03-28 04:46:29 +01:00
committed by Myx
parent c0cfca39a2
commit 35fd50c728
17 changed files with 382 additions and 80 deletions

View File

@@ -0,0 +1,47 @@
import { databaseService } from '../database/databaseService.js'
import { ChartData } from 'src-shared/interfaces/search.interface.js'
export async function addChart(chartData: ChartData): Promise<ChartData> {
try {
return await databaseService.insertChart(chartData)
} catch (error) {
console.error('Error in addChartHandler:', error)
throw error
}
}
export async function removeChart(md5: string): Promise<void> {
try {
await databaseService.removeChart(md5)
} catch (error) {
console.error('Error in removeChartHandler:', error)
throw error
}
}
export async function removeCharts(charts: ChartData[]): Promise<void> {
try {
await databaseService.removeCharts(charts)
} catch (error) {
console.error('Error in removeChartsHandler:', error)
throw error
}
}
export async function removeAllCharts(): Promise<void> {
try {
await databaseService.removeAllCharts()
} catch (error) {
console.error('Error in removeAllChartsHandler:', error)
throw error
}
}
export async function getChartsBySearchTerm(searchTerm?: string): Promise<ChartData[]> {
try {
return await databaseService.getChartsBySearchTerm(searchTerm)
} catch (error) {
console.error('Error in getChartsHandler:', error)
throw error
}
}