Skip to content
Snippets Groups Projects
Commit ae31dc3d authored by alrwasheda's avatar alrwasheda :speech_balloon:
Browse files

Wrapper-Functions commented, because sequelize functions can be used simply using Model.

parent d3b40390
No related branches found
No related tags found
No related merge requests found
......@@ -7,8 +7,8 @@ interface WorkerAttributes {
password: string;
role: string;
}
export interface WorkerInput extends Optional<WorkerAttributes, "email"> { }
export interface WorkerOutput extends Required<WorkerAttributes> { }
export interface WorkerInput extends Optional<WorkerAttributes, "email"> {}
export interface WorkerOutput extends Required<WorkerAttributes> {}
class Worker extends Model<WorkerAttributes> implements WorkerAttributes {
public email!: string;
public firstName: string;
......@@ -20,38 +20,40 @@ class Worker extends Model<WorkerAttributes> implements WorkerAttributes {
public readonly updatedAt!: Date;
}
export const initWorker = async (sequelizeConnection: Sequelize) => {
Worker.init(
{
email: {
type: new DataTypes.STRING(),
allowNull: false,
primaryKey: true,
unique: true,
},
firstName: {
type: new DataTypes.STRING(),
allowNull: false,
},
lastName: {
type: new DataTypes.STRING(),
allowNull: false,
},
password: {
type: new DataTypes.STRING(),
allowNull: false,
},
role: {
type: new DataTypes.STRING(),
allowNull: false,
Worker.init(
{
email: {
type: new DataTypes.STRING(),
allowNull: false,
primaryKey: true,
unique: true,
},
firstName: {
type: new DataTypes.STRING(),
allowNull: false,
},
lastName: {
type: new DataTypes.STRING(),
allowNull: false,
},
password: {
type: new DataTypes.STRING(),
allowNull: false,
},
role: {
type: new DataTypes.STRING(),
allowNull: false,
},
},
},
{
tableName: "worker",
sequelize: sequelizeConnection,
}
);
}
{
tableName: "worker",
sequelize: sequelizeConnection,
}
);
};
/*
--------------------------all those wrapper-functions are not needed. Query-functions can be calles simply using Model---------------------------------------------------------
export const create = async (payload: Worker): Promise<WorkerOutput> => {
return await Worker.create(payload);
......@@ -92,5 +94,5 @@ export const WorkerService = {
deleteById,
getAll,
};
*/
export default Worker;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment