mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-24 05:17:16 +02:00
Experimenting with better-sqlite3
This commit is contained in:
parent
02edfb4963
commit
3d34b16340
@ -1,8 +1,9 @@
|
||||
export const Experiments = {
|
||||
loadPhotoMetadata: {
|
||||
name: 'loadPhotoMetadata',
|
||||
db: {
|
||||
name: 'SQlite',
|
||||
groups: {
|
||||
exifr: 'exifr', exifrAll: 'exifrAll', exifrSelected: 'exifrSelected', exifreader: 'exifreader', exiftool: 'exiftool'
|
||||
sqlite3: 'sqlite3',
|
||||
betterSqlite: 'better-sqlite'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ services:
|
||||
volumes:
|
||||
- "./pigallery2/benchmark_config:/app/data/config" # CHANGE ME
|
||||
- "db-benchmark-data:/app/data/db"
|
||||
- "./pigallery2/images:/app/data/images" # CHANGE ME, ':ro' mean read-only
|
||||
- "./pigallery2/images:/app/data/images:ro" # CHANGE ME, ':ro' mean read-only
|
||||
- "./pigallery2/tmp:/app/data/tmp" # CHANGE ME
|
||||
expose:
|
||||
- "80"
|
||||
|
25
package-lock.json
generated
25
package-lock.json
generated
@ -4630,6 +4630,15 @@
|
||||
"integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=",
|
||||
"dev": true
|
||||
},
|
||||
"better-sqlite3": {
|
||||
"version": "7.5.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-7.5.0.tgz",
|
||||
"integrity": "sha512-6FdG9DoytYGDhLW7VWW1vxjEz7xHkqK6LnaUQYA8d6GHNgZhu9PFX2xwKEEnSBRoT1J4PjTUPeg217ShxNmuPg==",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"prebuild-install": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"big.js": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||
@ -4648,6 +4657,14 @@
|
||||
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||
"dev": true
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"bl": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz",
|
||||
@ -8351,6 +8368,11 @@
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-9.0.0.tgz",
|
||||
"integrity": "sha512-Qe/5NJrgIOlwijpq3B7BEpzPFcgzggOTagZmkXQY4LA6bsXKTUstK7Wp12lEJ/mLKTpvIZxmIuRcLYWT6ov9lw=="
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"filelist": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz",
|
||||
@ -8924,6 +8946,7 @@
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.12.1"
|
||||
}
|
||||
},
|
||||
@ -19967,6 +19990,7 @@
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.12.1"
|
||||
}
|
||||
},
|
||||
@ -20682,6 +20706,7 @@
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.12.1"
|
||||
}
|
||||
},
|
||||
|
@ -35,6 +35,7 @@
|
||||
"dependencies": {
|
||||
"archiver": "5.3.0",
|
||||
"bcrypt": "5.0.1",
|
||||
"better-sqlite3": "^7.5.0",
|
||||
"cookie-parser": "1.4.6",
|
||||
"cookie-session": "2.0.0",
|
||||
"csurf": "1.11.0",
|
||||
|
@ -22,6 +22,7 @@ import {DatabaseType, ServerDataBaseConfig, SQLLogLevel} from '../../../../commo
|
||||
import {AlbumBaseEntity} from './enitites/album/AlbumBaseEntity';
|
||||
import {SavedSearchEntity} from './enitites/album/SavedSearchEntity';
|
||||
import {NotificationManager} from '../../NotifocationManager';
|
||||
import {ActiveExperiments, Experiments} from '../../../../../benchmark/Experiments';
|
||||
|
||||
const LOG_TAG = '[SQLConnection]';
|
||||
|
||||
@ -34,6 +35,12 @@ export class SQLConnection {
|
||||
}
|
||||
|
||||
public static async getConnection(): Promise<Connection> {
|
||||
if (ActiveExperiments[Experiments.db.name] === Experiments.db.groups.sqlite3) {
|
||||
Config.Server.Database.type = DatabaseType.sqlite;
|
||||
}
|
||||
if (ActiveExperiments[Experiments.db.name] === Experiments.db.groups.betterSqlite) {
|
||||
Config.Server.Database.type = DatabaseType.better_sqlite3;
|
||||
}
|
||||
if (this.connection == null) {
|
||||
const options: any = this.getDriver(Config.Server.Database);
|
||||
// options.name = 'main';
|
||||
@ -223,6 +230,11 @@ export class SQLConnection {
|
||||
type: 'sqlite',
|
||||
database: path.join(ProjectPath.getAbsolutePath(config.dbFolder), config.sqlite.DBFileName)
|
||||
};
|
||||
} else if (config.type === DatabaseType.better_sqlite3) {
|
||||
driver = {
|
||||
type: 'better-sqlite3',
|
||||
database: path.join(ProjectPath.getAbsolutePath(config.dbFolder), 'better_', config.sqlite.DBFileName)
|
||||
};
|
||||
}
|
||||
return driver;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import {SortingMethods} from '../../entities/SortingMethods';
|
||||
import {UserRoles} from '../../entities/UserDTO';
|
||||
|
||||
export enum DatabaseType {
|
||||
memory = 1, mysql = 2, sqlite = 3
|
||||
memory = 1, mysql = 2, sqlite = 3, better_sqlite3
|
||||
}
|
||||
|
||||
export enum LogLevel {
|
||||
|
Loading…
x
Reference in New Issue
Block a user