rahvatarkus order by creation date, latest first
This commit is contained in:
parent
46287d6984
commit
6847b6605c
1 changed files with 2 additions and 2 deletions
|
@ -1,8 +1,7 @@
|
||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import { db } from '$lib/server/db';
|
import { db } from '$lib/server/db';
|
||||||
import { questions, answers } from '$lib/server/db/schema';
|
import { questions, answers } from '$lib/server/db/schema';
|
||||||
import { eq, gt, sql } from 'drizzle-orm';
|
import { desc, eq, gt, sql } from 'drizzle-orm';
|
||||||
import type { Question } from '$lib/types';
|
|
||||||
|
|
||||||
export async function GET({ params }) {
|
export async function GET({ params }) {
|
||||||
const limit = Math.min(parseInt(params.limit) || 10, 10);
|
const limit = Math.min(parseInt(params.limit) || 10, 10);
|
||||||
|
@ -30,6 +29,7 @@ export async function GET({ params }) {
|
||||||
))`
|
))`
|
||||||
})
|
})
|
||||||
.from(questions)
|
.from(questions)
|
||||||
|
.orderBy(desc(questions.createdAt))
|
||||||
.innerJoin(answers, eq(questions.id, answers.questionId))
|
.innerJoin(answers, eq(questions.id, answers.questionId))
|
||||||
.where(gt(questions.answerCount, 0))
|
.where(gt(questions.answerCount, 0))
|
||||||
.groupBy(questions.id)
|
.groupBy(questions.id)
|
||||||
|
|
Loading…
Add table
Reference in a new issue