Update database to use id of User table as user id
This commit is contained in:
parent
6c2233790e
commit
d7412cb71a
2 changed files with 1 additions and 14 deletions
|
@ -2,7 +2,6 @@ CREATE TABLE `user` (
|
||||||
`Id` varchar(255) NOT NULL,
|
`Id` varchar(255) NOT NULL,
|
||||||
`WhenCreated` datetime NOT NULL,
|
`WhenCreated` datetime NOT NULL,
|
||||||
`WhenUpdated` datetime NOT NULL,
|
`WhenUpdated` datetime NOT NULL,
|
||||||
`UserId` varchar(255) NOT NULL,
|
|
||||||
`Currency` int NOT NULL,
|
`Currency` int NOT NULL,
|
||||||
PRIMARY KEY (`Id`)
|
PRIMARY KEY (`Id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
@ -1,31 +1,19 @@
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity } from "typeorm";
|
||||||
import AppBaseEntity from "../../../contracts/AppBaseEntity";
|
import AppBaseEntity from "../../../contracts/AppBaseEntity";
|
||||||
import AppDataSource from "../../dataSources/appDataSource";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class User extends AppBaseEntity {
|
export default class User extends AppBaseEntity {
|
||||||
constructor(userId: string, currency: number) {
|
constructor(userId: string, currency: number) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.UserId = userId;
|
this.Id = userId;
|
||||||
this.Currency = currency;
|
this.Currency = currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column()
|
|
||||||
UserId: string;
|
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
Currency: number;
|
Currency: number;
|
||||||
|
|
||||||
public UpdateCurrency(currency: number) {
|
public UpdateCurrency(currency: number) {
|
||||||
this.Currency = currency;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue