mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 11:42:21 +03:00
38 lines
833 B
TypeScript
38 lines
833 B
TypeScript
import { DataSource } from "typeorm";
|
|
import {
|
|
DownloadQueue,
|
|
DownloadSource,
|
|
Game,
|
|
GameShopCache,
|
|
Repack,
|
|
UserPreferences,
|
|
} from "@main/entity";
|
|
import type { BetterSqlite3ConnectionOptions } from "typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions";
|
|
|
|
import { databasePath } from "./constants";
|
|
import migrations from "./migrations";
|
|
import { UserAuth } from "./entity/user-auth";
|
|
|
|
export const createDataSource = (
|
|
options: Partial<BetterSqlite3ConnectionOptions>
|
|
) =>
|
|
new DataSource({
|
|
type: "better-sqlite3",
|
|
entities: [
|
|
Game,
|
|
Repack,
|
|
UserPreferences,
|
|
GameShopCache,
|
|
DownloadSource,
|
|
DownloadQueue,
|
|
UserAuth,
|
|
],
|
|
synchronize: true,
|
|
database: databasePath,
|
|
...options,
|
|
});
|
|
|
|
export const dataSource = createDataSource({
|
|
migrations,
|
|
});
|