mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
👔 调整数据库检测,为后续可能的新数据库做准备
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file plugins/Sqlite/index.ts
|
* @file plugins/Sqlite/index.ts
|
||||||
* @description Sqlite 数据库操作类
|
* @description Sqlite 数据库操作类
|
||||||
* @since Beta v0.4.1
|
* @since Beta v0.4.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { app } from "@tauri-apps/api";
|
import { app } from "@tauri-apps/api";
|
||||||
@@ -173,20 +173,18 @@ class Sqlite {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 检测数据库完整性
|
* @description 检测数据库完整性
|
||||||
* @since Beta v0.3.3
|
* @since Beta v0.4.4
|
||||||
* @returns {Promise<boolean>}
|
* @returns {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
public async check(): Promise<boolean> {
|
public async check(): Promise<boolean> {
|
||||||
const db = await this.getDB();
|
const db = await this.getDB();
|
||||||
let isVerified = false;
|
let isVerified = false;
|
||||||
// 检测数据表是否都存在
|
|
||||||
const sqlT = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;";
|
const sqlT = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;";
|
||||||
const res: Array<{ name: string }> = await db.select(sqlT);
|
const res: Array<{ name: string }> = await db.select(sqlT);
|
||||||
if (res.length === this.tables.length) {
|
// 只检测已有的表是否具备,不检测总表数目
|
||||||
if (this.tables.every((item) => res.map((i) => i.name).includes(item))) {
|
if (this.tables.every((item) => res.map((i) => i.name).includes(item))) {
|
||||||
isVerified = true;
|
isVerified = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return isVerified;
|
return isVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user