mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-19 09:13:57 +00:00
first commit
This commit is contained in:
33
src/main/data-source.ts
Normal file
33
src/main/data-source.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { DataSource } from "typeorm";
|
||||
import {
|
||||
Game,
|
||||
GameShopCache,
|
||||
ImageCache,
|
||||
Repack,
|
||||
RepackerFriendlyName,
|
||||
UserPreferences,
|
||||
MigrationScript,
|
||||
} from "@main/entity";
|
||||
import type { SqliteConnectionOptions } from "typeorm/driver/sqlite/SqliteConnectionOptions";
|
||||
|
||||
import { databasePath } from "./constants";
|
||||
|
||||
export const createDataSource = (options: Partial<SqliteConnectionOptions>) =>
|
||||
new DataSource({
|
||||
type: "sqlite",
|
||||
database: databasePath,
|
||||
entities: [
|
||||
Game,
|
||||
ImageCache,
|
||||
Repack,
|
||||
RepackerFriendlyName,
|
||||
UserPreferences,
|
||||
GameShopCache,
|
||||
MigrationScript,
|
||||
],
|
||||
...options,
|
||||
});
|
||||
|
||||
export const dataSource = createDataSource({
|
||||
synchronize: true,
|
||||
});
|
||||
Reference in New Issue
Block a user