forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix SQL abstraction in SharedPhotoView.vue
- Add missing temp table service methods (, ) - Replace raw SQL with proper service method calls - Update TypeScript interfaces for temp methods - Complete Phase 2 SQL abstraction migration - Extend migration time to 11 minutes (corrected completion)
This commit is contained in:
@@ -47,6 +47,7 @@ import type {
|
||||
import { MASTER_SETTINGS_KEY, type Settings } from "@/db/tables/settings";
|
||||
import { logger } from "@/utils/logger";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { Temp } from "@/db/tables/temp";
|
||||
import { QueryExecResult, DatabaseExecResult } from "@/interfaces/database";
|
||||
import {
|
||||
generateInsertStatement,
|
||||
@@ -954,6 +955,41 @@ export const PlatformServiceMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
// =================================================
|
||||
// TEMP TABLE METHODS (for temporary storage)
|
||||
// =================================================
|
||||
|
||||
/**
|
||||
* Get temporary data by ID - $getTemp()
|
||||
* Retrieves temporary data from the temp table
|
||||
* @param id Temporary storage ID
|
||||
* @returns Promise<Temp | null> Temporary data or null if not found
|
||||
*/
|
||||
async $getTemp(id: string): Promise<Temp | null> {
|
||||
try {
|
||||
return await this.$first<Temp>("SELECT * FROM temp WHERE id = ?", [id]);
|
||||
} catch (error) {
|
||||
logger.error("[PlatformServiceMixin] Error getting temp data:", error);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete temporary data by ID - $deleteTemp()
|
||||
* Removes temporary data from the temp table
|
||||
* @param id Temporary storage ID
|
||||
* @returns Promise<boolean> Success status
|
||||
*/
|
||||
async $deleteTemp(id: string): Promise<boolean> {
|
||||
try {
|
||||
await this.$dbExec("DELETE FROM temp WHERE id = ?", [id]);
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.error("[PlatformServiceMixin] Error deleting temp data:", error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generic entity insertion - $insertEntity()
|
||||
* Eliminates verbose INSERT patterns for any entity
|
||||
@@ -1261,6 +1297,8 @@ export interface IPlatformServiceMixin {
|
||||
did: string,
|
||||
settings: Partial<Settings>,
|
||||
): Promise<boolean>;
|
||||
$getTemp(id: string): Promise<Temp | null>;
|
||||
$deleteTemp(id: string): Promise<boolean>;
|
||||
|
||||
// Logging methods
|
||||
$log(message: string, level?: string): Promise<void>;
|
||||
@@ -1381,6 +1419,8 @@ declare module "@vue/runtime-core" {
|
||||
did: string,
|
||||
settings: Partial<Settings>,
|
||||
): Promise<boolean>;
|
||||
$getTemp(id: string): Promise<Temp | null>;
|
||||
$deleteTemp(id: string): Promise<boolean>;
|
||||
|
||||
// Logging methods
|
||||
$log(message: string, level?: string): Promise<void>;
|
||||
|
||||
Reference in New Issue
Block a user