Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Crud Examples in Documentation #7

Closed
gerhardcit opened this issue Sep 12, 2024 · 3 comments
Closed

More Crud Examples in Documentation #7

gerhardcit opened this issue Sep 12, 2024 · 3 comments

Comments

@gerhardcit
Copy link

gerhardcit commented Sep 12, 2024

Could you provide examples on how to use delete, patch etc as well.
New to Convex and so far the svelte examples are VERY basic.
Its fine to query a db, but what about the CRUD operations? It would really help if you can expand on how that is used.

Convex docs are mostly based around React examples. Which is not helpful.

eg: I have
/src/convex/tasks.ts

import { mutation } from "./_generated/server";
import { v } from "convex/values";

export const deleteTask = mutation({
  args: { id: v.id("tasks") },
  // args: { id: v.string() },
  handler: async (ctx, args) => {
    await ctx.db.delete(args.id);
  },
});

then in src/routes/page.svelte

import { useConvexClient } from 'convex-svelte';
const client = useConvexClient();

const deleteTask = async (taskId: string) => {
       await client.mutation(api.tasks.deleteTask, { id: taskId });
};

But then this: How do I send an id?

image
@andrewwebbdeveloper
Copy link

Early days for me with TS and Convex - but using a type assertion works. { id: taskId as Id<'tasks'> }

I expect at some point the taskId string has to be cast to that type.

@programmingenjoyer219
Copy link

programmingenjoyer219 commented Nov 15, 2024

I've built this simple todo-application using Convex and Sveltekit, this project aims to implement CRUD functionality in a modularized way. Here's the link to the GitHub repo of the project: https://github.com/programmingenjoyer219/convex-sveltekit-todo-app

Your suggestions and modifications to the project will be appreciated.

@thomasballinger
Copy link
Collaborator

Please see demos at https://github.com/get-convex/convex-demos and docs https://docs.convex.dev/home for this — convex-svelte just exposes queries (the R part of CRUD) and mutations (the C, U, and D of CRUD) to a Svelte application. Writing a backend remains the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants