### Install project dependencies Source: https://github.com/get-convex/convex-test/blob/main/CONTRIBUTING.md Run this command to install all required project dependencies. ```bash npm install ``` -------------------------------- ### Publish project releases Source: https://github.com/get-convex/convex-test/blob/main/CONTRIBUTING.md Commands for publishing standard, alpha, or version-specific releases. ```bash npm run release ``` ```bash npm run alpha ``` ```bash npm version major ``` ```bash npm version minor ``` -------------------------------- ### Use a Convex Query in React Source: https://github.com/get-convex/convex-test/blob/main/convex/README.md Invoke a Convex query function from a React component using the `useQuery` hook. Pass the API path and arguments. ```typescript const data = useQuery(api.functions.myQueryFunction, { first: 10, second: "hello", }); ``` -------------------------------- ### Define a Convex Query Function Source: https://github.com/get-convex/convex-test/blob/main/convex/README.md Define a query function with argument validators and implement its logic. Use `ctx.db.query` to read data. Arguments are accessed via the `args` object. ```typescript // functions.js import { query } from "./_generated/server"; import { v } from "convex/values"; export const myQueryFunction = query({ // Validators for arguments. args: { first: v.number(), second: v.string(), }, // Function implementation. handler: async (ctx, args) => { // Read the database as many times as you need here. // See https://docs.convex.dev/database/reading-data. const documents = await ctx.db.query("tablename").collect(); // Arguments passed from the client are properties of the args object. console.log(args.first, args.second); // Write arbitrary JavaScript here: filter, aggregate, build derived data, // remove non-public properties, or create new objects. return documents; }, }); ``` -------------------------------- ### Define a Convex Mutation Function Source: https://github.com/get-convex/convex-test/blob/main/convex/README.md Define a mutation function with argument validators and implement its logic. Use `ctx.db.insert` or `ctx.db.get` to modify or read data. ```typescript // functions.js import { mutation } from "./_generated/server"; import { v } from "convex/values"; export const myMutationFunction = mutation({ // Validators for arguments. args: { first: v.string(), second: v.string(), }, // Function implementation. handler: async (ctx, args) => { // Insert or modify documents in the database here. // Mutations can also read from the database like queries. // See https://docs.convex.dev/database/writing-data. const message = { body: args.first, author: args.second }; const id = await ctx.db.insert("messages", message); // Optionally, return a value from your mutation. return await ctx.db.get(id); }, }); ``` -------------------------------- ### Use a Convex Mutation in React Source: https://github.com/get-convex/convex-test/blob/main/convex/README.md Invoke a Convex mutation function from a React component using the `useMutation` hook. Mutations can be fired and forgotten or their results can be handled with Promises. ```typescript const mutation = useMutation(api.functions.myMutationFunction); function handleButtonPress() { // fire and forget, the most common way to use mutations mutation({ first: "Hello!", second: "me" }); // OR // use the result once the mutation has completed mutation({ first: "Hello!", second: "me" }).then((result) => console.log(result), ); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.