Skip to content

Commit

Permalink
fix schema tour guide
Browse files Browse the repository at this point in the history
  • Loading branch information
augustus281 committed May 19, 2024
1 parent 8e28e66 commit 0d95e68
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions server/src/models/tour_guide.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { DataTypes } = require("sequelize")
const sequelize = require("../database/connect.mysql")
const User = require("./user.model")
const { RoleUser } = require("../common/status")
const bcrypt = require('bcrypt');

class TourGuide extends User {}
TourGuide.init({
Expand Down Expand Up @@ -72,33 +71,5 @@ TourGuide.init({

}, { sequelize, modelName: 'tour_guide'})

const createTourGuideDefault = async () => {
try {
const tourGuides = [
{ email: '[email protected]', password: 'tourguide@123', role_user: RoleUser.TOUR_GUIDE },
{ email: '[email protected]', password: 'tourguide@123', role_user: RoleUser.TOUR_GUIDE },
{ email: '[email protected]', password: 'tourguide@123', role_user: RoleUser.TOUR_GUIDE },
]

for (const tourGuide of tourGuides) {
const existTourGuide = await TourGuide.findOne({ where: { email: tourGuide.email } });
if (!existTourGuide) {
const hashedPassword = await bcrypt.hash(guide.password, 10);
const tourGuideInstance = new TourGuide({
email: tourGuide.email,
password: hashedPassword,
role_user: tourGuide.role_user,
});

await tourGuideInstance.save();
}
}
} catch (error) {
throw new Error("Error: ", error)
}
}

createTourGuideDefault()

module.exports = TourGuide

0 comments on commit 0d95e68

Please sign in to comment.