Update database to use id of User table as user id
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful

This commit is contained in:
Ethan Lane 2024-04-25 17:33:17 +01:00
parent 6c2233790e
commit d7412cb71a
2 changed files with 1 additions and 14 deletions

View file

@ -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;

View file

@ -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<User | null> {
const repository = AppDataSource.getRepository(User);
const single = await repository.findOne({ where: { UserId: userId }});
return single;
}
}