Convex Functions

Learn how to use the Convex Functions to manage your data.

Video Tutorial Coming Soon!

Understand the Different Types of Convex Functions

Writing Your First Query

Creating Your First Mutation

Mutation consist of a different operation such as inserting, updating, and removing data from your database, check authentication or perform any other business logics.

convex/tasks.ts

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

export const createTask = mutation({
args: { text: v.string() },
handler: async (ctx, { text }) => {
return await ctx.db.insert("tasks", { text });
}
});
For more details on how to construct mutations with Convex, see the Convex Mutations.

Creating Your First Action

Action is used for interacting with External API such Stripe for processing payment.

convex/tasks.ts

import { action } from "./_generated/server";

export const sendNotification = action({
handler: async (ctx) => {
// Call external API
await fetch("https://api.example.com/notify");
}
});
For more details on how to use HTTP actions with Convex, see the Convex HTTP.

That's it! You've learned how to use mutation and manage queries in Convex. Now, give it a try and build your own queries and mutation. See you on the next one!

Next Steps

Learn how to use Stripe Payments in your application.

Stripe Integration

Integrating payment processing using the Stripe API for transactions.

For more information on Convex Functions, check out the official documentation:Convex Functions