From 0370b8e2fd575693354d1b3519bd53420905569b Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 15 Jun 2026 16:08:52 +0530 Subject: [PATCH] structure ready --- controller/answerUnanswerdQuestion.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/controller/answerUnanswerdQuestion.js b/controller/answerUnanswerdQuestion.js index 18a4a1b..a192ff7 100644 --- a/controller/answerUnanswerdQuestion.js +++ b/controller/answerUnanswerdQuestion.js @@ -3,8 +3,8 @@ const postgre = require('../database/postgre'); const AnsweredQuestions = async (req, res) => { try { - - const user_id = req.user.id; + + const user_id = req.user.id; const result = await postgre.query( 'SELECT * FROM useraskquestion WHERE user_id = $1 And status = $2 ORDER BY id DESC', @@ -27,12 +27,16 @@ const AnsweredQuestions = async (req, res) => { const UnansweredQuestions = async (req, res) => { try { - - const user_id = req.user.id; const result = await postgre.query( - 'SELECT * FROM useraskquestion WHERE user_id = $1 And status = $2 ORDER BY id DESC', - [user_id, '0'] + `SELECT + uaq.*, + u.name + FROM useraskquestion uaq + LEFT JOIN users u ON u.id = uaq.user_id + WHERE uaq.status = $1 + ORDER BY uaq.id DESC`, + ['0'] ); res.json({