hydra/src/main/data-source.ts
2024-05-03 19:51:13 +01:00

33 lines
728 B
TypeScript

import { DataSource } from "typeorm";
import {
Game,
GameShopCache,
Repack,
RepackerFriendlyName,
UserPreferences,
MigrationScript,
SteamGame,
} from "@main/entity";
import type { SqliteConnectionOptions } from "typeorm/driver/sqlite/SqliteConnectionOptions";
import { databasePath } from "./constants";
export const createDataSource = (options: Partial<SqliteConnectionOptions>) =>
new DataSource({
type: "better-sqlite3",
database: databasePath,
entities: [
Game,
Repack,
RepackerFriendlyName,
UserPreferences,
GameShopCache,
MigrationScript,
SteamGame,
],
...options,
});
export const dataSource = createDataSource({
synchronize: true,
});