Api handles updating title aswell.

This commit is contained in:
2021-01-03 23:02:27 +01:00
parent e6b1b692d6
commit 294a25b5a6
2 changed files with 5 additions and 5 deletions

View File

@@ -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)

View File

@@ -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,