Explorer
convex
convex/agents.ts
1import { query, mutation } from "./_generated/server";
2import { v } from "convex/values";
3
4export const list = query({
5 handler: async (ctx) => {
6 return await ctx.db.query("agents")
7 .order("desc")
8 .collect();
9 },
10});
11
12export const updateStatus = mutation({
13 args: {
14 id: v.id("agents"),
15 status: v.union(
16 v.literal("active"),
17 v.literal("idle"),
18 v.literal("error"),
19 v.literal("offline")
20 ),
21 },
22 handler: async (ctx, { id, status }) => {
23 await ctx.db.patch(id, { status, lastSeen: Date.now() });
24 },
25});
typescript25 lines561 charsUTF-8LF