-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create get comment controller Create function to authorize users Add test Add swagger documentation [Finishes #167942058]
- Loading branch information
Showing
13 changed files
with
387 additions
and
11 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
22 changes: 22 additions & 0 deletions
22
src/database/migrations/20190811124707-create-comment-like.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,22 @@ | ||
export const up = (queryInterface, Sequelize) => queryInterface.createTable('CommentLikes', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID | ||
}, | ||
userId: { | ||
type: Sequelize.UUID | ||
}, | ||
commentId: { | ||
type: Sequelize.UUID | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
export const down = queryInterface => queryInterface.dropTable('CommentLikes'); |
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,29 @@ | ||
export default (sequelize, DataTypes) => { | ||
const CommentLike = sequelize.define('CommentLike', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: DataTypes.UUID | ||
}, | ||
commentId: { | ||
allowNull: false, | ||
type: DataTypes.UUID | ||
}, | ||
}, {}); | ||
CommentLike.associate = (models) => { | ||
CommentLike.belongsTo(models.Comment, { | ||
foreignKey: 'commentId', | ||
onDelete: 'CASCADE' | ||
}); | ||
CommentLike.belongsTo(models.User, { | ||
foreignKey: 'userId', | ||
onDelete: 'CASCADE' | ||
}); | ||
}; | ||
return CommentLike; | ||
}; |
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
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,20 @@ | ||
export const up = queryInterface => queryInterface.bulkInsert('CommentLikes', [{ | ||
id: '42f20078-9e37-4bb2-8b53-f4eba5b6456e', | ||
userId: 'be84f364-36fd-466d-a892-54dee6cc09d7', | ||
commentId: '6a7b986e-1102-4e9a-83b0-cad7df993e1c', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, { | ||
id: '34ff4237-d579-478e-b10f-01862eb2cfe3', | ||
userId: 'be84f364-36fd-466d-a892-54dee6cc09d7', | ||
commentId: 'b84f246f-ba18-4f83-876d-145be90b494d', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, { | ||
id: '279fad7c-abc0-48f8-a637-0e3c97d87c9a', | ||
userId: 'fb94de4d-47ff-4079-89e8-b0186c0a3be8', | ||
commentId: 'b84f246f-ba18-4f83-876d-145be90b494d', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}], {}); | ||
export const down = queryInterface => queryInterface.bulkDelete('CommentLikes', 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
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.