Partypack/Server/Source/Handlers/Database.ts
2024-02-04 22:28:42 +01:00

47 lines
1.1 KiB
TypeScript

import { DataSource } from "typeorm";
import { ENVIRONMENT, SAVED_DATA_PATH } from "../Modules/Constants";
import { Song } from "../Schemas/Song";
import { ForcedCategory } from "../Schemas/ForcedCategory";
import { User } from "../Schemas/User";
import { Rating } from "../Schemas/Rating";
import { DiscordRole } from "../Schemas/DiscordRole";
export const DBSource = new DataSource({
type: "better-sqlite3",
database: `${SAVED_DATA_PATH}/Partypack${ENVIRONMENT !== "prod" ? `-${ENVIRONMENT}` : ""}.db`,
synchronize: true,
logging: false,
entities: [
Song,
ForcedCategory,
User,
Rating,
DiscordRole
/*join(__dirname, "..", "Schemas") + "\\*{.js,.ts}"*/ // does not work in prod
],
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
*/