add auto vacuum and shrink database button

This commit is contained in:
Louis Lam 2021-10-26 23:02:32 +08:00
parent 39ad8b4bb7
commit a9e319517a
4 changed files with 91 additions and 1 deletions

View file

@ -114,6 +114,7 @@ class Database {
// Change to WAL
await R.exec("PRAGMA journal_mode = WAL");
await R.exec("PRAGMA cache_size = -12000");
await R.exec("PRAGMA auto_vacuum = FULL");
console.log("SQLite config:");
console.log(await R.getAll("PRAGMA journal_mode"));
@ -374,6 +375,17 @@ class Database {
console.log("Nothing to restore");
}
}
static getSize() {
debug("Database.getSize()");
let stats = fs.statSync(Database.path);
debug(stats);
return stats.size;
}
static async shrink() {
await R.exec("VACUUM");
}
}
module.exports = Database;