Skip to content

Commit

Permalink
Add order & limit
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-mn-yral committed Nov 16, 2023
1 parent 81445ae commit 065adce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/experiments/src/lib/helpers/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }
Expand Down

0 comments on commit 065adce

Please sign in to comment.