-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-user login -user specifies the article's slug and platform to share on in the url -platform is checked to be valid -user is verified if they have alredy shared the article. -if never, the share is made on the specified platform -if they have shared the share is verified if it was on the specified platform -if it was on the specified platform, the share is removed from the database and the user can create it again -if it was not on the specified platform the share is created and added in the array of the previous share platforms [WIP #165413120]
- Loading branch information
Showing
10 changed files
with
657 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
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,42 @@ | ||
const shareMigration = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Shares', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
userId: { | ||
type: Sequelize.INTEGER, | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE', | ||
references: { | ||
model: 'Users', | ||
key: 'id' | ||
} | ||
}, | ||
titleSlug: { | ||
type: Sequelize.STRING, | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE', | ||
references: { | ||
model: 'Articles', | ||
key: 'slug' | ||
} | ||
}, | ||
platform: { | ||
type: Sequelize.ARRAY(Sequelize.STRING), | ||
defaultValue: ['neutral'] | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Shares') | ||
}; | ||
export default shareMigration; |
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 @@ | ||
const shares = (sequelize, DataTypes) => { | ||
const Share = sequelize.define('Share', { | ||
userId: DataTypes.INTEGER, | ||
titleSlug: DataTypes.STRING, | ||
platform: { | ||
type: DataTypes.ARRAY(DataTypes.STRING), | ||
defaultValue: ['neutral'] | ||
} | ||
}, {}); | ||
Share.associate = (models) => { | ||
Share.belongsTo(models.User, { | ||
foreignKey: 'userId', | ||
as: 'author', | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE' | ||
}); | ||
Share.belongsTo(models.Article, { | ||
foreignKey: 'titleSlug', | ||
targetKey: 'slug', | ||
onDelete: 'CASCADE', | ||
onUpdate: 'CASCADE' | ||
}); | ||
}; | ||
return Share; | ||
}; | ||
export default shares; |
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.