initial commit

This commit is contained in:
2025-10-21 11:06:46 -03:00
commit d00e0cd676
33 changed files with 1324 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import { query, mutation } from "./_generated/server";
import { v } from "convex/values";
export const getAll = query({
handler: async (ctx) => {
return await ctx.db.query("todos").collect();
},
});
export const create = mutation({
args: {
text: v.string(),
},
handler: async (ctx, args) => {
const newTodoId = await ctx.db.insert("todos", {
text: args.text,
completed: false,
});
return await ctx.db.get(newTodoId);
},
});
export const toggle = mutation({
args: {
id: v.id("todos"),
completed: v.boolean(),
},
handler: async (ctx, args) => {
await ctx.db.patch(args.id, { completed: args.completed });
return { success: true };
},
});
export const deleteTodo = mutation({
args: {
id: v.id("todos"),
},
handler: async (ctx, args) => {
await ctx.db.delete(args.id);
return { success: true };
},
});