-
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.
feature(bookmark): User can bookmark novels
- add enpoint to bookmark novels - add endpoint to fetch bookmarks - write test for edge cases [Finishes #167165000]
- Loading branch information
Showing
9 changed files
with
317 additions
and
13 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,32 @@ | ||
export const up = (queryInterface, Sequelize) => queryInterface.createTable('Bookmarks', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.UUID, | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: Sequelize.UUID, | ||
references: { | ||
model: 'Users', | ||
key: 'id' | ||
}, | ||
}, | ||
novelId: { | ||
allowNull: true, | ||
type: Sequelize.UUID, | ||
references: { | ||
model: 'Novels', | ||
key: 'id' | ||
}, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
export const down = queryInterface => queryInterface.dropTable('Bookmarks'); |
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 @@ | ||
export default (sequelize, DataTypes) => { | ||
const Bookmark = sequelize.define('Bookmark', { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: DataTypes.UUID, | ||
defaultValue: DataTypes.UUIDV4, | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: DataTypes.UUID | ||
}, | ||
novelId: { | ||
allowNull: false, | ||
type: DataTypes.UUID | ||
} | ||
}, {}); | ||
Bookmark.associate = (models) => { | ||
Bookmark.belongsTo(models.User, { | ||
foreignKey: 'userId', | ||
onDelete: 'CASCADE' | ||
}); | ||
|
||
Bookmark.belongsTo(models.Novel, { | ||
foreignKey: 'novelId', | ||
onDelete: 'CASCADE' | ||
}); | ||
}; | ||
return Bookmark; | ||
}; |
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
Oops, something went wrong.