62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
|
|
import {
|
||
|
|
DataTypes,
|
||
|
|
InferAttributes,
|
||
|
|
InferCreationAttributes,
|
||
|
|
Model,
|
||
|
|
Sequelize,
|
||
|
|
} from "sequelize";
|
||
|
|
|
||
|
|
export type TCreationUser_Attributes = InferCreationAttributes<User_Model>;
|
||
|
|
|
||
|
|
export class User_Model extends Model<
|
||
|
|
InferAttributes<User_Model>,
|
||
|
|
InferCreationAttributes<User_Model>
|
||
|
|
> {
|
||
|
|
// To avoid table creation
|
||
|
|
/*static async sync(): Promise<any> {
|
||
|
|
return Promise.resolve();
|
||
|
|
}*/
|
||
|
|
|
||
|
|
static associate(connection: Sequelize) {}
|
||
|
|
|
||
|
|
declare id: string;
|
||
|
|
declare email: string;
|
||
|
|
declare password: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export default (sequelize: Sequelize) => {
|
||
|
|
User_Model.init(
|
||
|
|
{
|
||
|
|
id: {
|
||
|
|
type: new DataTypes.UUID(),
|
||
|
|
primaryKey: true,
|
||
|
|
},
|
||
|
|
|
||
|
|
email: {
|
||
|
|
type: DataTypes.STRING,
|
||
|
|
allowNull: false,
|
||
|
|
},
|
||
|
|
password: {
|
||
|
|
type: DataTypes.STRING,
|
||
|
|
allowNull: false,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
sequelize,
|
||
|
|
tableName: "users",
|
||
|
|
|
||
|
|
//paranoid: true, // softs deletes
|
||
|
|
//timestamps: true,
|
||
|
|
//version: true,
|
||
|
|
|
||
|
|
//createdAt: "created_at",
|
||
|
|
//updatedAt: "updated_at",
|
||
|
|
//deletedAt: "deleted_at",
|
||
|
|
|
||
|
|
indexes: [{ name: "email_idx", unique: true, fields: ["email"] }],
|
||
|
|
},
|
||
|
|
);
|
||
|
|
|
||
|
|
return User_Model;
|
||
|
|
};
|