import {sequelize} from "../app"; import {DataTypes, InferAttributes, InferCreationAttributes, Model} from "sequelize"; export enum Rank { USER = "user", TEAM_MEMBER = "team", ADMIN = "admin" } export interface IUser extends Model, InferCreationAttributes> { clientId: number username: string locale?: string rank?: Rank avatarId?: string accessToken: string refreshToken: string refreshDate?: Date created?: Date } const UserSchema = sequelize.define('users', { clientId: { type: DataTypes.BIGINT, allowNull: false, primaryKey: true }, username: { type: DataTypes.STRING, defaultValue: "User#0001" }, locale: { type: DataTypes.STRING, defaultValue: "en" }, rank: { type: DataTypes.STRING, defaultValue: Rank.USER }, avatarId: { type: DataTypes.STRING, defaultValue: "590962a0d694945a779054cd078a7efd" }, accessToken: { type: DataTypes.STRING, allowNull: false }, refreshToken: { type: DataTypes.STRING, allowNull: false }, refreshDate: { type: DataTypes.DATE, allowNull: false }, created: { type: DataTypes.DATE, defaultValue: Date.now } }); export const User = UserSchema;