createTable.ts•512 B
import { v } from "convex/values";
import { mutationGeneric } from "../server";
export default mutationGeneric({
args: {
table: v.string(),
componentId: v.optional(v.union(v.string(), v.null())),
},
handler: async ({ db }, { table }) => {
// We don't have an "official" way to create a table without inserting documents,
// but inserting a document and deleting it in the same transaction is one way to do this.
const id = await db.insert(table, {});
await db.delete(id);
},
});