11# Welcome to your Convex functions directory!
22
3- Write your Convex functions here. See https://docs.convex.dev/functions for
4- more.
3+ Write your Convex functions here.
4+ See https://docs.convex.dev/functions for more.
55
66A query function that takes two arguments looks like:
77
88``` ts
9- // functions.js
9+ // convex/myFunctions.ts
1010import { query } from " ./_generated/server" ;
1111import { v } from " convex/values" ;
1212
@@ -36,7 +36,7 @@ export const myQueryFunction = query({
3636Using this query function in a React component looks like:
3737
3838``` ts
39- const data = useQuery (api .functions .myQueryFunction , {
39+ const data = useQuery (api .myFunctions .myQueryFunction , {
4040 first: 10 ,
4141 second: " hello" ,
4242});
@@ -45,7 +45,7 @@ const data = useQuery(api.functions.myQueryFunction, {
4545A mutation function looks like:
4646
4747``` ts
48- // functions.js
48+ // convex/myFunctions.ts
4949import { mutation } from " ./_generated/server" ;
5050import { v } from " convex/values" ;
5151
@@ -65,15 +65,15 @@ export const myMutationFunction = mutation({
6565 const id = await ctx .db .insert (" messages" , message );
6666
6767 // Optionally, return a value from your mutation.
68- return await ctx .db .get (id );
68+ return await ctx .db .get (" messages " , id );
6969 },
7070});
7171```
7272
7373Using this mutation function in a React component looks like:
7474
7575``` ts
76- const mutation = useMutation (api .functions .myMutationFunction );
76+ const mutation = useMutation (api .myFunctions .myMutationFunction );
7777function handleButtonPress() {
7878 // fire and forget, the most common way to use mutations
7979 mutation ({ first: " Hello!" , second: " me" });
@@ -85,6 +85,6 @@ function handleButtonPress() {
8585}
8686```
8787
88- Use the Convex CLI to push your functions to a deployment. See everything the
89- Convex CLI can do by running ` npx convex -h ` in your project root directory. To
90- learn more, launch the docs with ` npx convex docs ` .
88+ Use the Convex CLI to push your functions to a deployment. See everything
89+ the Convex CLI can do by running ` npx convex -h ` in your project root
90+ directory. To learn more, launch the docs with ` npx convex docs ` .
0 commit comments