import 'fake-indexeddb/auto' import { AriaEngine } from '/mnt/d/CodeWorkspace/MarkLite/node_modules/@metona-team/metona-sqlark/dist/metona-sqlark.esm.js' // 小 memtable 阈值 → 频繁 flush → 多个 SSTable + WAL const engine1 = new AriaEngine({ storageBackend: 'indexeddb', memtableSizeThreshold: 4096, walEnabled: true }) await engine1.open('flushkill-test', 1) await engine1.createTable({ name: 't', columns: { id: { type: 'string', primaryKey: true }, v: { type: 'number' } } }) // 写入大量数据触发多次 flush(写 WAL + 刷 SSTable) for (let i = 0; i < 3000; i++) { await engine1.insert('t', [{ id: `k${i}`, v: i }]) } console.log('S1 wrote 3000 rows') // 不 close!直接丢弃实例(模拟应用被强制关闭/渲染进程被销毁) // 重新打开同库 const engine2 = new AriaEngine({ storageBackend: 'indexeddb', memtableSizeThreshold: 4096, walEnabled: true }) await engine2.open('flushkill-test', 1) const tables = await engine2.getTableNames() console.log('S2 tables:', JSON.stringify(tables)) if (tables.includes('t')) { const rows = await engine2.find('t', { limit: 5 }) console.log('S2 sample rows:', JSON.stringify(rows)) console.log('REOPEN OK') } else { console.log('TABLE LOST') } await engine2.close()