Skip to main content
Glama
counter.ts735 B
import { Id } from "./_generated/dataModel"; import { mutation, query } from "./_generated/server"; export const get = query({ handler: async ({ db }, { counter }: { counter: Id<"counters"> }) => { const doc = await db.get(counter); if (!doc) throw new Error("no counter found"); return doc.count; }, }); export const create = mutation({ args: {}, handler: async ({ db }) => { return await db.insert("counters", { count: 0 }); }, }); export const increment = mutation({ handler: async ({ db }, { counter }: { counter: Id<"counters"> }) => { const doc = await db.get(counter); if (!doc) throw new Error("no counter found"); return await db.replace(counter, { count: doc.count + 1 }); }, });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/get-convex/convex-backend'

If you have feedback or need assistance with the MCP directory API, please join our Discord server