Compare commits

..

3 commits

Author SHA1 Message Date
Ethan Lane 6c2233790e Fix linting issues
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2024-04-16 19:06:43 +01:00
Ethan Lane d608e1c752 Create migration script 2024-04-16 19:05:39 +01:00
Ethan Lane ea27bed454 Create users entity 2024-04-16 19:05:28 +01:00
3 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,8 @@
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

@ -0,0 +1,31 @@
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.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;
}
}

View file

@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import MigrationHelper from "../../../../helpers/MigrationHelper";
export class User1713289062969 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
MigrationHelper.Up("1713289062969-user", "0.6", [
"01-table/User",
], queryRunner);
}
public async down(): Promise<void> {
}
}