Added reading profile endpoint
This commit is contained in:
@@ -20,7 +20,7 @@ async function create_post(req, res) {
|
||||
const imageLink = imageLinkForFile(req.file);
|
||||
try {
|
||||
const { rows } = await pool.query(
|
||||
"INSERT INTO posts (title, text, author_id, image_link) VALUES ($1, $2, $3, $4) RETURNING id, title, text, author_id, image_link",
|
||||
"WITH created AS (INSERT INTO posts (title, text, author_id, image_link) VALUES ($1, $2, $3, $4) RETURNING id, title, text, author_id, image_link, created_at) SELECT created.*, people.username AS author_username FROM created LEFT JOIN people ON people.id = created.author_id",
|
||||
[title, text, author_id, imageLink],
|
||||
);
|
||||
res.status(201).json(rows[0]);
|
||||
|
||||
Reference in New Issue
Block a user