Added reading profile endpoint
This commit is contained in:
@@ -9,8 +9,8 @@ const path = require("path");
|
||||
async function getPosts(req, res, ownOnly) {
|
||||
try {
|
||||
const query = ownOnly
|
||||
? "SELECT id, title, text, author_id, image_link FROM posts WHERE author_id = $1"
|
||||
: "SELECT id, title, text, author_id, image_link FROM posts";
|
||||
? "SELECT p.id, p.title, p.text, p.author_id, people.username AS author_username, p.image_link, p.created_at FROM posts p LEFT JOIN people ON people.id = p.author_id WHERE p.author_id = $1"
|
||||
: "SELECT p.id, p.title, p.text, p.author_id, people.username AS author_username, p.image_link, p.created_at FROM posts p LEFT JOIN people ON people.id = p.author_id";
|
||||
const values = ownOnly ? [req.user.id] : [];
|
||||
const { rows } = await pool.query(query, values);
|
||||
res.status(200).json(rows);
|
||||
|
||||
Reference in New Issue
Block a user