adjust so DB calls go to the factory

This commit is contained in:
2025-05-26 13:59:34 -06:00
parent bb0d8942b8
commit 0e10847cba
10 changed files with 86 additions and 19 deletions

View File

@@ -163,25 +163,25 @@
<div class="mt-8">
<h2 class="text-xl font-bold mb-4">SQL Operations</h2>
<div class="mb-4">
<div class="flex gap-2 mb-2">
<button
class="text-sm text-blue-600 hover:text-blue-800 underline"
@click="
sqlQuery = 'SELECT * FROM sqlite_master WHERE type=\'table\';'
"
>
All Tables
</button>
</div>
<div>
<textarea
v-model="sqlQuery"
class="w-full h-32 p-2 border border-gray-300 rounded-md font-mono"
placeholder="Enter your SQL query here..."
></textarea>
</div>
<div class="flex gap-2 mt-2">
<button
class="text-sm text-blue-600 hover:text-blue-800 underline"
@click="
sqlQuery = 'SELECT * FROM sqlite_master WHERE type=\'table\';'
"
>
All Tables
</button>
</div>
<div class="mb-4">
<div class="mt-4">
<button
class="font-bold capitalize bg-slate-500 text-white px-3 py-2 rounded-md mr-2"
@click="executeSql"
@@ -307,7 +307,6 @@ import { AppString, NotificationIface } from "../constants/app";
import { db, retrieveSettingsForActiveAccount } from "../db/index";
import * as vcLib from "../libs/crypto/vc";
import * as cryptoLib from "../libs/crypto";
import databaseService from "../services/database";
import {
PeerSetup,
@@ -323,6 +322,7 @@ import {
SHARED_PHOTO_BASE64_KEY,
} from "../libs/util";
import { logger } from "../utils/logger";
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
const inputFileNameRef = ref<Blob>();
const TEST_PAYLOAD = {
@@ -535,12 +535,13 @@ export default class Help extends Vue {
}
async executeSql() {
const platformService = PlatformServiceFactory.getInstance();
try {
const isSelect = this.sqlQuery.trim().toLowerCase().startsWith("select");
if (isSelect) {
this.sqlResult = await databaseService.query(this.sqlQuery);
this.sqlResult = await platformService.dbQuery(this.sqlQuery);
} else {
this.sqlResult = await databaseService.run(this.sqlQuery);
this.sqlResult = await platformService.dbExec(this.sqlQuery);
}
logger.log("SQL Result:", this.sqlResult);
} catch (error) {