hydra/src/main/data-source.ts

34 lines
728 B
TypeScript
Raw Normal View History

2024-04-21 05:26:29 +00:00
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,
});