convex
Version:
Client for the Convex Cloud
59 lines • 2.27 kB
TypeScript
/**
* Utilities for implementing server-side Convex query and mutation functions.
*
* ## Usage
*
* ### Code Generation
*
* This module is typically used alongside generated server code.
*
* To generate the server code, run `npx convex codegen` in your Convex project.
* This will create a `convex/_generated/server.js` file with the following
* functions, typed for your schema:
* - [query](https://docs.convex.dev/generated-api/server#query)
* - [mutation](https://docs.convex.dev/generated-api/server#mutation)
*
* If you aren't using TypeScript and code generation, you can use these untyped
* functions instead:
* - {@link queryGeneric}
* - {@link mutationGeneric}
*
* ### Example
*
* Convex functions are defined by using either the `query` or
* `mutation` wrappers.
*
* Queries receive a `db` that implements the {@link DatabaseReader} interface.
*
* ```ts
* import { query } from "./_generated/server";
*
* export default query(async ({ db }, ...args: any[]): Promise<any> => {
* // Your (read-only) code here!
* });
* ```
*
* If your function needs to write to the database, such as inserting, updating,
* or deleting documents, use `mutation` instead which provides a `db` that
* implements the {@link DatabaseWriter} interface.
*
* ```ts
* import { mutation } from "./_generated/server";
*
* export default mutation(async ({ db }, ...args: any[]): Promise<any> => {
* // Your mutation code here!
* });
* ```
* @module
*/
export * from "./database.js";
export type { Expression, ExpressionOrValue, FilterBuilder, } from "./filter_builder.js";
export type { OrderedQuery, Query, QueryInitializer } from "./query.js";
export type { Auth, UserIdentity } from "./authentication.js";
export type { PublicMutation, PublicQuery, PublicAction, MutationCtx, QueryCtx, ActionCtx, MutationBuilderForDataModel, QueryBuilderForDataModel, ActionBuilderForAPI, } from "./registration.js";
export { actionGeneric, mutationGeneric, queryGeneric, } from "./impl/registration_impl.js";
export * from "./data_model.js";
export type { IndexRangeBuilder, IndexRange } from "./index_range_builder.js";
export type { WithoutSystemFields } from "./system_fields";
export * from "./pagination.js";
//# sourceMappingURL=index.d.ts.map