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 { try {
const id = req.param('id') const id = req.param('id')
const value = req.param('url') 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) { 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) return res.json(url)
} else { } else {
await TargetUrl.destroyOne({ id }) return new HttpError(400, 'URL cannot be blank.').send(res)
return res.status(204).send()
} }
} catch (e) { } catch (e) {
return (new HttpError(500, e.message)).send(res) return (new HttpError(500, e.message)).send(res)

View File

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