mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 22:29:38 +00:00
Add database for library
This commit is contained in:
47
src-electron/ipc/LibraryHandler.ipc.ts
Normal file
47
src-electron/ipc/LibraryHandler.ipc.ts
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user