Skip to content

Commit af8ecec

Browse files
Scottsaf6260
authored andcommitted
Updating routes and tables to account for a new description field as well as a new public option on go links
1 parent e4d4a11 commit af8ecec

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

db/migrations/20150809163538-links.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export function up(queryInterface, Sequelize) {
99
type: Sequelize.STRING,
1010
allowNull: false,
1111
},
12+
goDescription: {
13+
type: Sequelize.STRING,
14+
allowNull: false,
15+
},
16+
publicGO: {
17+
type: Sequelize.STRING,
18+
allowNull: false,
19+
},
1220
createdAt: Sequelize.DATE,
1321
updatedAt: Sequelize.DATE,
1422
});

models/link.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,29 @@ export default sequelize.define('links', {
2121
},
2222
},
2323
},
24+
goDescription: {
25+
type: DataTypes.STRING,
26+
allowNull: false,
27+
validate: {
28+
notEmpty: true
29+
}
30+
},
31+
publicGO: {
32+
type: DataTypes.STRING,
33+
allowNull: false,
34+
validate: {
35+
notEmpty: true
36+
},
37+
},
2438
}, {
2539
scopes: {
2640
paginate,
2741
orderBy(field, direction) {
2842
return sorting(field, direction, [
2943
'shortLink',
3044
'longLink',
45+
'goDescription',
46+
'publicGO',
3147
'createdAt',
3248
'updatedAt',
3349
]);

routes/links.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ router
2424
.catch(err => next(err));
2525
})
2626
.post(needs('links', 'create'), (req, res, next) => {
27+
console.log('public go value: ' + req.body.publicGO);
2728
Link.create({
2829
shortLink: req.body.shortLink.toLocaleLowerCase(),
2930
longLink: req.body.longLink,
30-
}, { fields: ['shortLink', 'longLink'] })
31+
goDescription: req.body.goDescription,
32+
publicGO: req.body.publicGO,
33+
}, { fields: ['shortLink', 'longLink', 'goDescription', 'publicGO'] })
3134
.then(link => res.status(201).send(link))
3235
.catch((err) => {
3336
err.status = 422;
@@ -71,7 +74,7 @@ router
7174
.then((link) => {
7275
if (link) {
7376
return link.updateAttributes(req.body, {
74-
fields: ['shortLink', 'longLink'],
77+
fields: ['shortLink', 'longLink', 'goDescription', 'publicGO'],
7578
});
7679
}
7780
return Promise.reject({ message: 'Link not found', status: 404 });

0 commit comments

Comments
 (0)