server.js
This code is generated
These exports are not directly available in the convex
package!
Instead you must run npx convex codegen
to create
convex/_generated/server.js
and convex/_generated/server.d.ts
.
Generated utilities for implementing server-side Convex query and mutation functions.
Functions
query
▸ query<F
>(func: F
):
PublicQuery
<DataModel
, F
>
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.
This is an alias of queryGeneric
that is
typed for your app's data model.
Type parameters
Name | Type |
---|---|
F | extends (ctx : QueryCtx , ...args : any ) => any |
Parameters
Name | Type | Description |
---|---|---|
func | F | The query function. It receives a QueryCtx as its first argument. |
Returns
PublicQuery
<DataModel
, F
>
The wrapped query. Include this as an export
to name it and make it
accessible.
mutation
▸ mutation<F
>(func: F
):
PublicMutation
<DataModel
, F
>
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.
This is an alias of mutationGeneric
that is typed for your app's data model.
Type parameters
Name | Type |
---|---|
F | extends (ctx : MutationCtx , ...args : any ) => any |
Parameters
Name | Type | Description |
---|---|---|
func | F | The mutation function. It receives a MutationCtx as its first argument. |
Returns
PublicMutation
<DataModel
, F
>
The wrapped mutation. Include this as an export
to name it and make it
accessible.
Types
QueryCtx
Ƭ QueryCtx: Object
A set of services for use within Convex query functions.
The query context is passed as the first argument to any Convex query function run on the server.
This differs from the MutationCtx because all of the services are read-only.
This is an alias of QueryCtx
that is typed for
your app's data model.
Type declaration
Name | Type |
---|---|
db | DatabaseReader |
auth | Auth |
MutationCtx
Ƭ MutationCtx: Object
A set of services for use within Convex mutation functions.
The mutation context is passed as the first argument to any Convex mutation function run on the server.
This is an alias of MutationCtx
that is
typed for your app's data model.
Type declaration
Name | Type |
---|---|
db | DatabaseWriter |
auth | Auth |
DatabaseReader
An interface to read from the database within Convex query functions.
This is an alias of DatabaseReader
that is typed for your app's data model.
DatabaseWriter
An interface to read from and write to the database within Convex mutation functions.
This is an alias of DatabaseWriter
that is typed for your app's data model.