Create users entity

This commit is contained in:
Ethan Lane 2024-04-16 19:05:28 +01:00
parent bcbd0855b8
commit ea27bed454

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