finished user store in typscript

This commit is contained in:
canove
2020-09-14 18:54:36 -03:00
parent eba3553a2d
commit 7f33e33078
29 changed files with 260 additions and 133 deletions

View File

@@ -0,0 +1,26 @@
import {
Table,
Column,
CreatedAt,
UpdatedAt,
Model,
PrimaryKey
} from "sequelize-typescript";
@Table
class Setting extends Model<Setting> {
@PrimaryKey
@Column
key: string;
@Column
value: string;
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}
export default Setting;

View File

@@ -15,7 +15,7 @@ class User extends Model<User> {
@Column
name: string;
@Column
@Column(DataType.STRING)
email: string;
@Column(DataType.VIRTUAL)
@@ -43,12 +43,12 @@ class User extends Model<User> {
}
};
// static checkPassword = async ( // maybe not work like this.
// instance: User,
// password: string
// ): Promise<boolean> => {
// return compare(password, instance.passwordHash);
// };
public checkPassword = async (
// maybe not work like this.
password: string
): Promise<boolean> => {
return compare(password, this.getDataValue("passwordHash"));
};
}
export default User;