fix: 修复 transaction 表名与 Dexie 内置方法冲突(导出 JSON 与记账失效)

This commit is contained in:
root
2026-10-16 13:19:54 +08:00
parent f0d30e2c29
commit 5a67b2f59a
10 changed files with 57 additions and 42 deletions
+3 -3
View File
@@ -35,13 +35,13 @@ function rowHash(row: AnyRow): string {
}
async function getTable(name: string): Promise<AnyRow[]> {
return (db as unknown as AnyRow)[name].toArray()
return db.table(name).toArray()
}
// 一次性补齐 uuid 与 updated_at,缺失时回填
async function ensureSyncFields(): Promise<void> {
for (const t of TABLES) {
const table = (db as unknown as AnyRow)[t]
const table = db.table(t)
const rows: AnyRow[] = await table.toArray()
for (const row of rows) {
if (t === 'setting' && EXCLUDE_SETTING_KEYS.has(row.key)) continue
@@ -287,7 +287,7 @@ async function doRunSync(config: SyncConfig): Promise<SyncResult> {
const finalMirror: { table: string; uuid: string; hash: string }[] = []
for (const t of TABLES) {
const table = (db as unknown as AnyRow)[t]
const table = db.table(t)
const localRows: AnyRow[] = await table.toArray()
const byUuid = new Map<string, AnyRow>()
for (const row of localRows) byUuid.set(row.uuid, row)