0.0.67 • Published 2 years ago
@convex-dev/server v0.0.67
@convex-dev/server
Server library for Convex functions to interact with data in the Convex Cloud.
Usage
Convex functions are defined by using either the query
or mutation
functions.
Queries receive a db
that implements the
DatabaseReader
interface.
import { query } from "@convex-dev/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
DatabaseWriter
interface.
import { mutation } from "@convex-dev/server";
export default mutation(async ({ db }, ...args: any[]): Promise<any> => {
// Your mutation code here!
});
See the Convex Getting Started guide for more details on how to get started.
See also
- @convex-dev/browser is the library used by client-side code running in the browser to interact with Convex server-side functions.
- @convex-dev/react is a layer on top of @convex-dev/browser that provides React hooks for data binding to Convex functions.
- @convex-dev/cli is the CLI tool for spinning up Convex backends and syncing functions.