Create concept of currency in the database #209

Merged
Vylpes merged 4 commits from feature/200-currency-db into develop 2024-04-26 18:35:03 +01:00
Showing only changes of commit ea27bed454 - Show all commits

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;
Vylpes marked this conversation as resolved
Review

Would it be worth having this as the main primary key ID? I can't see that not being unique

Would it be worth having this as the main primary key ID? I can't see that not being unique
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;
}
}