-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ledouxm/feat/change-orm
Feat/change orm
- Loading branch information
Showing
55 changed files
with
1,669 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
PORT = 3002 | ||
HTTPS = TRUE | ||
|
||
TYPEORM_CONNECTION = sqlite | ||
TYPEORM_HOST = localhost | ||
TYPEORM_USERNAME = root | ||
TYPEORM_PASSWORD = admin | ||
TYPEORM_DATABASE = database/lol-stalker.db | ||
TYPEORM_PORT = 3000 | ||
TYPEORM_SYNCHRONIZE = false | ||
TYPEORM_ENTITIES = **/entities/*.js | ||
TYPEORM_MIGRATIONS_DIR = migration | ||
TYPEORM_MIGRATIONS = migration/*.js | ||
|
||
TYPEORM_LOGGING = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ yarn-error.log* | |
*.tgz | ||
|
||
*.db-journal | ||
lol-stalker.db.dev | ||
*/prismaClient | ||
database/** | ||
|
||
selectedFriends.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import isDev from "electron-is-dev"; | ||
import path from "path"; | ||
import sqlite3 from "sqlite3"; | ||
import { PrismaClient } from "./prismaClient"; | ||
const dbUrl = isDev ? "lol-stalker.db.dev" : "lol-stalker.db"; | ||
|
||
export const db = new sqlite3.Database(dbUrl); | ||
import { createConnection } from "typeorm"; | ||
const dbUrl = path.join(__dirname, "database", "lol-stalker.db"); | ||
// export const db = new sqlite3.Database(dbUrl); | ||
|
||
export const prisma = isDev | ||
? new PrismaClient({ | ||
datasources: { | ||
db: { url: `file://${path.join(__dirname, "../" + dbUrl).replace("C:\\", "")}` }, | ||
}, | ||
// log: ["query", "info", "warn", "error"], | ||
}) | ||
: new PrismaClient(); | ||
export const makeDb = () => | ||
isDev | ||
? createConnection() | ||
: createConnection({ | ||
type: "sqlite", | ||
database: dbUrl, | ||
entities: [path.join(__dirname, "entities/*")], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Column, Entity, OneToMany } from "typeorm"; | ||
import { Ranking } from "./Ranking"; | ||
import { FriendName } from "./FriendName"; | ||
import { Notification } from "./Notification"; | ||
|
||
@Entity("Friend") | ||
export class Friend { | ||
@Column("text", { primary: true, name: "puuid", unique: true }) | ||
puuid: string; | ||
|
||
@Column("text", { name: "id", nullable: true }) | ||
id: string | null; | ||
|
||
@Column("text", { name: "gameName" }) | ||
gameName: string; | ||
|
||
@Column("text", { name: "gameTag", nullable: true }) | ||
gameTag: string | null; | ||
|
||
@Column("integer", { name: "groupId", default: () => "0" }) | ||
groupId: number; | ||
|
||
@Column("text", { name: "groupName", default: () => "'NONE'" }) | ||
groupName: string; | ||
|
||
@Column("text", { name: "name" }) | ||
name: string; | ||
|
||
@Column("integer", { name: "summonerId" }) | ||
summonerId: number; | ||
|
||
@Column("integer", { name: "icon" }) | ||
icon: number; | ||
|
||
@Column("datetime", { name: "createdAt", default: () => "CURRENT_TIMESTAMP" }) | ||
createdAt: Date; | ||
|
||
@Column("boolean", { name: "isCurrentSummoner", default: () => "false" }) | ||
isCurrentSummoner: boolean; | ||
|
||
@OneToMany(() => Ranking, (ranking) => ranking.friend) | ||
rankings: Ranking[]; | ||
|
||
@OneToMany(() => FriendName, (friendName) => friendName.friend) | ||
friendNames: FriendName[]; | ||
|
||
@OneToMany(() => Notification, (notification) => notification.friend) | ||
notifications: Notification[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; | ||
import { Friend } from "./Friend"; | ||
|
||
@Entity("FriendName") | ||
export class FriendName { | ||
@PrimaryGeneratedColumn({ type: "integer", name: "id" }) | ||
id: number; | ||
|
||
@Column("text", { name: "name", default: () => "''" }) | ||
name: string; | ||
|
||
@Column("datetime", { name: "createdAt", default: () => "CURRENT_TIMESTAMP" }) | ||
createdAt: Date; | ||
|
||
@ManyToOne(() => Friend, (friend) => friend.friendNames, { | ||
onDelete: "RESTRICT", | ||
onUpdate: "CASCADE", | ||
}) | ||
@JoinColumn([{ name: "puuid", referencedColumnName: "puuid" }]) | ||
friend: Friend; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; | ||
import { Friend } from "./Friend"; | ||
|
||
@Entity("Notification") | ||
export class Notification { | ||
@PrimaryGeneratedColumn({ type: "integer", name: "id" }) | ||
id: number; | ||
|
||
@Column("text", { name: "type", default: () => "''" }) | ||
type: string; | ||
|
||
@Column("text", { name: "from" }) | ||
from: string; | ||
|
||
@Column("text", { name: "to" }) | ||
to: string; | ||
|
||
@Column("text", { name: "content" }) | ||
content: string; | ||
|
||
@Column("datetime", { name: "createdAt", default: () => "CURRENT_TIMESTAMP" }) | ||
createdAt: Date; | ||
|
||
@Column("boolean", { name: "isNew", default: () => "true" }) | ||
isNew: boolean; | ||
|
||
@ManyToOne(() => Friend, (friend) => friend.notifications, { | ||
onDelete: "RESTRICT", | ||
onUpdate: "CASCADE", | ||
}) | ||
@JoinColumn([{ name: "puuid", referencedColumnName: "puuid" }]) | ||
friend: Friend; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; | ||
import { Friend } from "./Friend"; | ||
|
||
@Entity("Ranking") | ||
export class Ranking { | ||
@PrimaryGeneratedColumn({ type: "integer", name: "id" }) | ||
id: number; | ||
|
||
@Column("text", { name: "division" }) | ||
division: string; | ||
|
||
@Column("text", { name: "tier" }) | ||
tier: string; | ||
|
||
@Column("integer", { name: "leaguePoints" }) | ||
leaguePoints: number; | ||
|
||
@Column("integer", { name: "wins" }) | ||
wins: number; | ||
|
||
@Column("integer", { name: "losses" }) | ||
losses: number; | ||
|
||
@Column("text", { name: "miniSeriesProgress", default: () => "''" }) | ||
miniSeriesProgress: string; | ||
|
||
@Column("datetime", { name: "createdAt", default: () => "CURRENT_TIMESTAMP" }) | ||
createdAt: Date; | ||
|
||
@ManyToOne(() => Friend, (friend) => friend.rankings, { | ||
onDelete: "RESTRICT", | ||
onUpdate: "CASCADE", | ||
}) | ||
@JoinColumn([{ name: "puuid", referencedColumnName: "puuid" }]) | ||
friend: Friend; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.