Files
spoon/packages/backend/convex/syncRuns.ts
T
Gabriel Brown cf7ff2ee4e
Build and Push Next App / quality (push) Failing after 45s
Build and Push Next App / build-next (push) Has been skipped
Initial commit for project Spoon!
2026-06-21 17:52:02 -05:00

31 lines
916 B
TypeScript

import { v } from 'convex/values';
import { query } from './_generated/server';
import { getOwnedSpoon, getRequiredUserId } from './model';
export const listRecent = query({
args: { limit: v.optional(v.number()) },
handler: async (ctx, { limit }) => {
const ownerId = await getRequiredUserId(ctx);
const runs = await ctx.db
.query('syncRuns')
.withIndex('by_owner', (q) => q.eq('ownerId', ownerId))
.order('desc')
.take(limit ?? 25);
return runs;
},
});
export const listForSpoon = query({
args: { spoonId: v.id('spoons'), limit: v.optional(v.number()) },
handler: async (ctx, { spoonId, limit }) => {
const ownerId = await getRequiredUserId(ctx);
await getOwnedSpoon(ctx, spoonId, ownerId);
return await ctx.db
.query('syncRuns')
.withIndex('by_spoon', (q) => q.eq('spoonId', spoonId))
.order('desc')
.take(limit ?? 25);
},
});