diff --git a/api/post.js b/api/post.js index 043f526..9b89279 100644 --- a/api/post.js +++ b/api/post.js @@ -24,10 +24,10 @@ class PostRepository { return this.database.get(query, [id]) } - updatePost(id, markdown="## database testost") { - const query = `UPDATE posts SET markdown = $1 WHERE id = $2`; + updatePost(id, markdown="## database testost", title="undefined title") { + const query = `UPDATE posts SET markdown = $1, title = $2 WHERE id = $3`; - const post = this.database.update(query, [markdown, id]); + const post = this.database.update(query, [markdown, title, id]); return post .then(post => true) diff --git a/api/webserver/controllers/postController.js b/api/webserver/controllers/postController.js index 5a42f97..88a1ead 100644 --- a/api/webserver/controllers/postController.js +++ b/api/webserver/controllers/postController.js @@ -25,9 +25,9 @@ function renderPost(req, res) { function updatePost(req, res) { const { id } = req.params; - const { markdown } = req.body; + const { markdown, title } = req.body; - return postRepository.updatePost(id, markdown) + return postRepository.updatePost(id, markdown, title) .then(fileUpdated => res.json({ message: "Successfully updated post " + id, filename: fileUpdated,