mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-15 04:32:13 +00:00
34 lines
728 B
TypeScript
34 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,
|
||
|
});
|