This commit is contained in:
AndrewTrieu
2023-03-12 12:43:33 +02:00
parent f14618b7cc
commit d6d09df845
11 changed files with 28 additions and 31 deletions

View File

@@ -8,6 +8,7 @@ const countAnswers = async () => {
const getAnswersByQuestionId = async (questionId) => {
const result =
await sql`SELECT * FROM question_answer_options WHERE question_id = ${questionId}`;
console.log(result);
return result;
};

View File

@@ -6,26 +6,23 @@ const addTopic = async (userId, name) => {
const countTopics = async () => {
const result = await sql`SELECT COUNT(id) FROM topics`;
console.log(result);
console.log(result[0].count);
return result[0].count;
};
const getAllTopics = async () => {
const result = await sql`SELECT * FROM topics ORDER BY name ASC`;
console.log(result);
return result;
};
const getTopicsByUserId = async (userId) => {
const result =
await sql`SELECT * FROM topics WHERE user_id = ${userId} ORDER BY name ASC`;
console.log(result);
return result;
};
const getTopicByTopicId = async (topicId) => {
const result = await sql`SELECT * FROM topics WHERE id = ${topicId}`;
console.log(result);
return result[0];
};