-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Convex example for v0.2.0 (#41143)
## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
1 parent
76235a7
commit ed4eeb9
Showing
8 changed files
with
144 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* eslint-disable */ | ||
/** | ||
* Generated data model types. | ||
* | ||
* THIS CODE IS AUTOMATICALLY GENERATED. | ||
* | ||
* Generated by convex@0.2.0. | ||
* To regenerate, run `npx convex codegen`. | ||
* @module | ||
*/ | ||
|
||
import { GenericId } from "convex/values"; | ||
|
||
/** | ||
* An identifier for a document in Convex. | ||
* | ||
* Convex documents are uniquely identified by their `Id`, which is accessible | ||
* on the `_id` field. To learn more, see [Data Modeling](https://docs.convex.dev/using/data-modeling). | ||
* | ||
* Documents can be loaded using `db.get(id)` in query and mutation functions. | ||
* | ||
* **Important**: Use `myId.equals(otherId)` to check for equality. | ||
* Using `===` will not work because two different instances of `Id` can refer | ||
* to the same document. | ||
*/ | ||
export const Id = GenericId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable */ | ||
/** | ||
* Generated React hooks. | ||
* | ||
* THIS CODE IS AUTOMATICALLY GENERATED. | ||
* | ||
* Generated by convex@0.2.0. | ||
* To regenerate, run `npx convex codegen`. | ||
* @module | ||
*/ | ||
|
||
import { | ||
useQueryGeneric, | ||
useMutationGeneric, | ||
useConvexGeneric, | ||
} from "convex/react"; | ||
|
||
/** | ||
* Load a reactive query within a React component. | ||
* | ||
* This React hook contains internal state that will cause a rerender whenever | ||
* the query result changes. | ||
* | ||
* This relies on the {@link ConvexProvider} being above in the React component tree. | ||
* | ||
* @param name - The name of the query function. | ||
* @param args - The arguments to the query function. | ||
* @returns `undefined` if loading and the query's return value otherwise. | ||
*/ | ||
export const useQuery = useQueryGeneric; | ||
|
||
/** | ||
* Construct a new {@link ReactMutation}. | ||
* | ||
* Mutation objects can be called like functions to request execution of the | ||
* corresponding Convex function, or further configured with | ||
* [optimistic updates](https://docs.convex.dev/using/optimistic-updates). | ||
* | ||
* The value returned by this hook is stable across renders, so it can be used | ||
* by React dependency arrays and memoization logic relying on object identity | ||
* without causing rerenders. | ||
* | ||
* This relies on the {@link ConvexProvider} being above in the React component tree. | ||
* | ||
* @param name - The name of the mutation. | ||
* @returns The {@link ReactMutation} object with that name. | ||
*/ | ||
export const useMutation = useMutationGeneric; | ||
|
||
/** | ||
* Get the {@link ConvexReactClient} within a React component. | ||
* | ||
* This relies on the {@link ConvexProvider} being above in the React component tree. | ||
* | ||
* @returns The active {@link ConvexReactClient} object, or `undefined`. | ||
*/ | ||
export const useConvex = useConvexGeneric; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable */ | ||
/** | ||
* Generated utilities for implementing server-side Convex query and mutation functions. | ||
* | ||
* THIS CODE IS AUTOMATICALLY GENERATED. | ||
* | ||
* Generated by convex@0.2.0. | ||
* To regenerate, run `npx convex codegen`. | ||
* @module | ||
*/ | ||
|
||
import { queryGeneric, mutationGeneric } from "convex/server"; | ||
|
||
/** | ||
* Define a query in this Convex app's public API. | ||
* | ||
* This function will be allowed to read your Convex database and will be accessible from the client. | ||
* | ||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument. | ||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible. | ||
*/ | ||
export const query = queryGeneric; | ||
|
||
/** | ||
* Define a mutation in this Convex app's public API. | ||
* | ||
* This function will be allowed to modify your Convex database and will be accessible from the client. | ||
* | ||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. | ||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. | ||
*/ | ||
export const mutation = mutationGeneric; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters