-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from DucHuy2801/fix-bug
Add feature relate tour guide
- Loading branch information
Showing
4 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict' | ||
|
||
const { DataTypes, Model } = require('sequelize'); | ||
const sequelize = require('../database/connect.mysql'); | ||
const TourGuide = require('./tour_guide.model'); | ||
const Tour = require('./tour.model'); | ||
|
||
class GuideTour extends Model {} | ||
GuideTour.init({ | ||
id: { | ||
type: DataTypes.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
tour_guide_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: true, | ||
}, | ||
tour_id: { | ||
type: DataTypes.INTEGER, | ||
allowNull: true, | ||
} | ||
}, { sequelize, modelName: "guide_tour" }) | ||
|
||
TourGuide.belongsToMany(Tour, { through: GuideTour, foreignKey: "tour_guide_id" }) | ||
Tour.belongsToMany(TourGuide, { through: GuideTour, foreignKey: "tour_id" }) | ||
|
||
module.exports = GuideTour | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters