From d7412cb71a202b43ba6d706c76e91dde1446c459 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 25 Apr 2024 17:33:17 +0100 Subject: [PATCH] Update database to use id of User table as user id --- .../0.6/1713289062969-user/Up/01-table/User.sql | 1 - src/database/entities/app/User.ts | 14 +------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/database/0.6/1713289062969-user/Up/01-table/User.sql b/database/0.6/1713289062969-user/Up/01-table/User.sql index aa7c36b..86a5d36 100644 --- a/database/0.6/1713289062969-user/Up/01-table/User.sql +++ b/database/0.6/1713289062969-user/Up/01-table/User.sql @@ -2,7 +2,6 @@ CREATE TABLE `user` ( `Id` varchar(255) NOT NULL, `WhenCreated` datetime NOT NULL, `WhenUpdated` datetime NOT NULL, - `UserId` varchar(255) NOT NULL, `Currency` int NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; \ No newline at end of file diff --git a/src/database/entities/app/User.ts b/src/database/entities/app/User.ts index 26d1303..c954aea 100644 --- a/src/database/entities/app/User.ts +++ b/src/database/entities/app/User.ts @@ -1,31 +1,19 @@ import { Column, Entity } from "typeorm"; import AppBaseEntity from "../../../contracts/AppBaseEntity"; -import AppDataSource from "../../dataSources/appDataSource"; @Entity() export default class User extends AppBaseEntity { constructor(userId: string, currency: number) { super(); - this.UserId = userId; + this.Id = userId; this.Currency = currency; } - @Column() - UserId: string; - @Column() Currency: number; public UpdateCurrency(currency: number) { this.Currency = currency; } - - public static async FetchOneByUserId(userId: string): Promise { - const repository = AppDataSource.getRepository(User); - - const single = await repository.findOne({ where: { UserId: userId }}); - - return single; - } } \ No newline at end of file