mirror of
https://github.com/djhackersdev/minime.git
synced 2026-04-22 17:27:30 -05:00
sql: Add db compaction method
This commit is contained in:
parent
13e234a68c
commit
151dd41e64
|
|
@ -18,4 +18,6 @@ export interface Transaction {
|
|||
|
||||
export interface DataSource {
|
||||
transaction<T>(callback: (txn: Transaction) => Promise<T>): Promise<T>;
|
||||
|
||||
vacuum(): Promise<void>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,14 @@ class SqliteDataSource implements DataSource {
|
|||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
vacuum(): Promise<void> {
|
||||
const db = new Database(this._path);
|
||||
|
||||
db.prepare("vacuum").run();
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
export function openSqlite(path: string): DataSource {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user