// Query
export const all = queryWithAuth({
args: { amount: v.number() },
handler: async (ctx, args) => {
const videos = await ctx.db.query('videos').order('desc').take(args.amount)
return await Promise.all(
videos.map(async (video) => await enrichWithExtras(ctx, video))
)
},
})
// example
import { api } from 'backend/convex/_generated/api'
import { useQuery } from '@/lib/usingSession'
const SomeComponent = () => {
const videos = useQuery(api.queries.videos.all, { amount: 80 }) // This returns videos with it's inferred type
// ... rest of component
}
// Query
export const all = queryWithAuth({
args: { amount: v.number() },
handler: async (ctx, args) => {
const videos = await ctx.db.query('videos').order('desc').take(args.amount)
return await Promise.all(
videos.map(async (video) => await enrichWithExtras(ctx, video))
)
},
})
// example
import { api } from 'backend/convex/_generated/api'
import { useQuery } from '@/lib/usingSession'
const SomeComponent = () => {
const videos = useQuery(api.queries.videos.all, { amount: 80 }) // This returns videos with it's inferred type
// ... rest of component
}