- Update the user entity to be nullable in the typescript side - The migration script already did this, but if you have the `DB_SYNC` environment variable sync it then it doesn't get set to nullable #353 Reviewed-on: #371 Reviewed-by: VylpesTester <tester@vylpes.com> Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
34 lines
No EOL
758 B
TypeScript
34 lines
No EOL
758 B
TypeScript
import { Column, Entity } from "typeorm";
|
|
import AppBaseEntity from "../../../contracts/AppBaseEntity";
|
|
|
|
@Entity()
|
|
export default class User extends AppBaseEntity {
|
|
constructor(userId: string, currency: number) {
|
|
super();
|
|
|
|
this.Id = userId;
|
|
this.Currency = currency;
|
|
}
|
|
|
|
@Column()
|
|
Currency: number;
|
|
|
|
@Column({ nullable: true })
|
|
LastUsedDaily?: Date;
|
|
|
|
public AddCurrency(amount: number) {
|
|
this.Currency += amount;
|
|
}
|
|
|
|
public RemoveCurrency(amount: number): boolean {
|
|
if (this.Currency < amount) return false;
|
|
|
|
this.Currency -= amount;
|
|
|
|
return true;
|
|
}
|
|
|
|
public UpdateLastUsedDaily(lastUsedDaily: Date) {
|
|
this.LastUsedDaily = lastUsedDaily;
|
|
}
|
|
} |