-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Book Accommodation): implement accommodation booking
- create a booking accommodation controller - create booking accommodation route - create a validation schema - test accommodation booking endpoint - update search route [Maintains #167727754]
- Loading branch information
Showing
11 changed files
with
462 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
58 changes: 58 additions & 0 deletions
58
src/database/migrations/20190905112508-create-book-accomodation.js
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,58 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.createTable('BookAccomodations', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID | ||
}, | ||
userId: { | ||
type: Sequelize.UUID, | ||
allowNull: false | ||
}, | ||
accommodationId: { | ||
type: Sequelize.UUID, | ||
allowNull: false | ||
}, | ||
roomType: { | ||
type: Sequelize.ARRAY(Sequelize.STRING), | ||
allowNull: false | ||
}, | ||
checkIn: { | ||
type: Sequelize.DATE, | ||
allowNull: false | ||
}, | ||
checkOut: { | ||
type: Sequelize.DATE, | ||
allowNull: false | ||
}, | ||
numOfRooms: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
defaultValue: 1 | ||
}, | ||
adults: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
defaultValue: 1 | ||
}, | ||
children: { | ||
type: Sequelize.INTEGER, | ||
allowNull: true, | ||
defaultValue: 0 | ||
}, | ||
createdAt: { | ||
allowNull: true, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: true, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
}, | ||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.dropTable('BookAccomodations'); | ||
} | ||
}; |
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,56 @@ | ||
module.exports = (sequelize, DataTypes) => { | ||
const BookAccomodation = sequelize.define('BookAccomodation', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
userId: { | ||
type: DataTypes.UUID, | ||
allowNull: false, | ||
}, | ||
accommodationId: { | ||
type: DataTypes.UUID, | ||
allowNull: false | ||
}, | ||
roomType: { | ||
type: DataTypes.ARRAY(DataTypes.STRING), | ||
allowNull: false | ||
}, | ||
checkIn: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
checkOut: { | ||
type: DataTypes.DATE, | ||
allowNull: false | ||
}, | ||
numOfRooms: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
defaultValue: 1 | ||
}, | ||
adults: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
defaultValue: 1 | ||
}, | ||
children: { | ||
type: DataTypes.INTEGER, | ||
allowNull: true, | ||
defaultValue: 0 | ||
} | ||
}, {}); | ||
BookAccomodation.associate = (models) => { | ||
BookAccomodation.belongsTo(models.User, { | ||
foreignKey: 'userId', | ||
as: 'User', | ||
}); | ||
BookAccomodation.belongsTo(models.Accommodation, { | ||
foreignKey: 'accommodationId', | ||
as: 'Accommodation', | ||
}); | ||
}; | ||
return BookAccomodation; | ||
}; |
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
Oops, something went wrong.