Api handles updating title aswell.
This commit is contained in:
@@ -24,10 +24,10 @@ class PostRepository {
|
|||||||
return this.database.get(query, [id])
|
return this.database.get(query, [id])
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePost(id, markdown="## database testost") {
|
updatePost(id, markdown="## database testost", title="undefined title") {
|
||||||
const query = `UPDATE posts SET markdown = $1 WHERE id = $2`;
|
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
|
return post
|
||||||
.then(post => true)
|
.then(post => true)
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ function renderPost(req, res) {
|
|||||||
|
|
||||||
function updatePost(req, res) {
|
function updatePost(req, res) {
|
||||||
const { id } = req.params;
|
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({
|
.then(fileUpdated => res.json({
|
||||||
message: "Successfully updated post " + id,
|
message: "Successfully updated post " + id,
|
||||||
filename: fileUpdated,
|
filename: fileUpdated,
|
||||||
|
|||||||
Reference in New Issue
Block a user