feat: enable caching in typeorm connection options
The cache still needs to be explicitly used in each query, this commit only enables the orm to do so.
This commit is contained in:
parent
b202c270bc
commit
60eb8fb9fa
|
@ -3,6 +3,7 @@
|
|||
library:
|
||||
type: sqlite
|
||||
database: ./test-paths/typeorm/library.db
|
||||
cache: true
|
||||
entities:
|
||||
- ./src/main/entities/library/*.js
|
||||
migrations:
|
||||
|
|
|
@ -15,6 +15,7 @@ const connectionOptions: MyConnectionOptions = Object.values(Databases).reduce(
|
|||
prev[database] = {
|
||||
type: 'sqlite',
|
||||
database: path.resolve(databasePath, `${database}.db`),
|
||||
cache: true,
|
||||
entities: [`./src/main/entities/${database}/*.js`],
|
||||
migrations: [`./src/main/migrations/${database}/*.js`],
|
||||
cli: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class initialMigration1587423043395 implements MigrationInterface {
|
||||
name = 'initialMigration1587423043395';
|
||||
export class initialMigration1587513640202 implements MigrationInterface {
|
||||
name = 'initialMigration1587513640202';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
|
@ -683,9 +683,14 @@ export class initialMigration1587423043395 implements MigrationInterface {
|
|||
`CREATE INDEX "IDX_1f53233757f73a30345a845b36" ON "work_author_author_roles_author_role" ("authorRoleId") `,
|
||||
undefined
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "query-result-cache" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "identifier" varchar, "time" bigint NOT NULL, "duration" integer NOT NULL, "query" text NOT NULL, "result" text NOT NULL)`,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "query-result-cache"`, undefined);
|
||||
await queryRunner.query(`DROP INDEX "IDX_1f53233757f73a30345a845b36"`, undefined);
|
||||
await queryRunner.query(`DROP INDEX "IDX_ad6eb15a9e307bbc0071e45584"`, undefined);
|
||||
await queryRunner.query(
|
Loading…
Reference in New Issue