-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(accommodation): create feature for users to comment/give feed…
…back on accommodation facilities
- Loading branch information
Showing
6 changed files
with
157 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Comments', { | ||
id: { | ||
type: Sequelize.UUID, | ||
primaryKey: true, | ||
defaultValue: Sequelize.UUIDV4, | ||
}, | ||
username: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
accommodationFacility: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
userId: { | ||
type: Sequelize.UUID, | ||
references: { | ||
model: 'Users', | ||
key: 'id' | ||
} | ||
}, | ||
comment: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
profileImage: { | ||
type: Sequelize.STRING | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
}), | ||
|
||
down: queryInterface => queryInterface.dropTable('Comments') | ||
}; |
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,34 @@ | ||
export default (sequelize, DataTypes) => { | ||
const Comment = sequelize.define('Comment', { | ||
id: { | ||
type: DataTypes.UUID, | ||
primaryKey: true, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
username: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
userId: DataTypes.UUID, | ||
accommodationFacility: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
comment: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
profileImage: { | ||
type: DataTypes.STRING | ||
} | ||
}); | ||
|
||
Comment.associate = models => { | ||
Comment.belongsTo(models.User, { | ||
foreignKey: 'userId', | ||
onDelete: 'CASCADE' | ||
}); | ||
}; | ||
|
||
return Comment; | ||
}; |
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,26 @@ | ||
module.exports = { | ||
up: queryInterface => queryInterface.bulkInsert('Comments', [ | ||
{ | ||
id: '2125be7b-f1f1-4f0a-af86-49c657870b5c', | ||
userId: '3821b930-ce48-4ac8-9ddf-ee3bf7980d08', | ||
username: 'gmemmy', | ||
accommodationFacility: 'Eko Hotels and Suites', | ||
comment: 'The best hotel there is for a barefoot nomad.', | ||
profileImage: 'https://www.google.com/url?sa=i&source=images&cd=&ved=2ahUKEwiP', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
id: '4712fc7e-ca41-457f-872e-4a64b79efbba', | ||
userId: '3821b930-ce48-4ac8-9ddf-ee3bf7980d08', | ||
username: 'JohnDoe', | ||
accommodationFacility: 'Eko Hotels and Suites', | ||
comment: 'A home away from home. Top notch service.', | ||
profileImage: 'https://www.google.com/url?sa=i&source=images&cd=&ved=2ahUKEwiP', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
} | ||
], {}), | ||
|
||
down: queryInterface => queryInterface.bulkDelete('Comments', null, {}) | ||
}; |
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