|
|
@ -4,6 +4,7 @@ const { R } = require("redbean-node");
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
setSetting, setting,
|
|
|
|
setSetting, setting,
|
|
|
|
} = require("./util-server");
|
|
|
|
} = require("./util-server");
|
|
|
|
|
|
|
|
const knex = require("knex");
|
|
|
|
|
|
|
|
|
|
|
|
class Database {
|
|
|
|
class Database {
|
|
|
|
|
|
|
|
|
|
|
@ -12,6 +13,24 @@ class Database {
|
|
|
|
static latestVersion = 5;
|
|
|
|
static latestVersion = 5;
|
|
|
|
static noReject = true;
|
|
|
|
static noReject = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static connect() {
|
|
|
|
|
|
|
|
const Dialect = require("knex/lib/dialects/sqlite3/index.js");
|
|
|
|
|
|
|
|
Dialect.prototype._driver = () => require("@louislam/sqlite3");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R.setup(knex({
|
|
|
|
|
|
|
|
client: Dialect,
|
|
|
|
|
|
|
|
connection: {
|
|
|
|
|
|
|
|
filename: Database.path,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
useNullAsDefault: true,
|
|
|
|
|
|
|
|
pool: {
|
|
|
|
|
|
|
|
min: 1,
|
|
|
|
|
|
|
|
max: 1,
|
|
|
|
|
|
|
|
idleTimeoutMillis: 30000,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static async patch() {
|
|
|
|
static async patch() {
|
|
|
|
let version = parseInt(await setting("database_version"));
|
|
|
|
let version = parseInt(await setting("database_version"));
|
|
|
|
|
|
|
|
|
|
|
|