Partypack/Server/Source/Handlers/Database.ts

47 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-01-22 00:41:59 +01:00
import { DataSource } from "typeorm";
2024-02-04 00:36:28 +01:00
import { ENVIRONMENT, SAVED_DATA_PATH } from "../Modules/Constants";
2024-01-28 11:07:10 +01:00
import { Song } from "../Schemas/Song";
import { ForcedCategory } from "../Schemas/ForcedCategory";
import { User } from "../Schemas/User";
import { Rating } from "../Schemas/Rating";
2024-02-04 22:28:42 +01:00
import { DiscordRole } from "../Schemas/DiscordRole";
2024-01-22 00:41:59 +01:00
export const DBSource = new DataSource({
type: "better-sqlite3",
2024-02-04 00:36:28 +01:00
database: `${SAVED_DATA_PATH}/Partypack${ENVIRONMENT !== "prod" ? `-${ENVIRONMENT}` : ""}.db`,
2024-01-22 00:41:59 +01:00
synchronize: true,
logging: false,
2024-01-28 11:07:10 +01:00
entities: [
Song,
ForcedCategory,
User,
2024-02-04 22:28:42 +01:00
Rating,
DiscordRole
2024-01-28 11:07:10 +01:00
/*join(__dirname, "..", "Schemas") + "\\*{.js,.ts}"*/ // does not work in prod
],
2024-01-22 00:41:59 +01:00
subscribers: [],
migrations: [],
enableWAL: true
});
(async () => {
await DBSource.initialize();
})();
/*
User
- discord id (primary)
- list of all songs in user's library
- list of all songs in user's published
Song
- length
- bpm
- key
- scale
- keytar/guitar
- icon url
- name
- artist
- release year
*/