From 065adceaf7f61c5671eeeba9b14f8ad7534a9230 Mon Sep 17 00:00:00 2001 From: harshbaz Date: Thu, 16 Nov 2023 09:35:38 +0530 Subject: [PATCH] Add order & limit --- packages/experiments/src/lib/helpers/feed.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/experiments/src/lib/helpers/feed.ts b/packages/experiments/src/lib/helpers/feed.ts index a182edcf7..cb561e4a4 100644 --- a/packages/experiments/src/lib/helpers/feed.ts +++ b/packages/experiments/src/lib/helpers/feed.ts @@ -4,6 +4,7 @@ import { getDocs, limit, QueryDocumentSnapshot, + orderBy, } from 'firebase/firestore' import type { CollectionName, UpDownPost } from '../db/db.types' import { getDb } from '$lib/db' @@ -13,7 +14,11 @@ export async function getVideos(lastRef?: QueryDocumentSnapshot) { console.log({ lastRef }) const videos: UpDownPost[] = [] const db = getDb() - const q = query(collection(db, 'ud-videos' as CollectionName), limit(30)) + const q = query( + collection(db, 'ud-videos' as CollectionName), + orderBy('created_at', 'desc'), + limit(50), + ) const snapshot = await getDocs(q) if (snapshot.empty) { return { ok: true, videos, more: false }