update models and controller for filters

pull/32/head
unknown 2018-11-19 18:37:40 -05:00
parent 5a6454a047
commit 5e468e71e0
2 changed files with 17 additions and 4 deletions

View File

@ -22,12 +22,21 @@ module.exports = {
try {
const id = req.param('id')
const value = req.param('url')
const author = req.param('author')
const publisher = req.param('publisher')
const title = req.param('title')
const isbn = req.param('isbn')
if (value.length) {
const url = await TargetUrl.update({ id, user: req.user.id }, { url: value }).fetch()
const url = await TargetUrl.update({ id, user: req.user.id }, {
url: value,
author,
publisher,
title,
isbn
}).fetch()
return res.json(url)
} else {
await TargetUrl.destroyOne({ id })
return res.status(204).send()
return new HttpError(400, 'URL cannot be blank.').send(res)
}
} catch (e) {
return (new HttpError(500, e.message)).send(res)

View File

@ -11,6 +11,10 @@ module.exports = {
},
url: {
type: 'string'
}
},
author: 'string',
publisher: 'string',
title: 'string',
isbn: 'string'
}
}