Use database client
The database client is an export of the Prisma client from the @prisma/client
package. It is automatically generated by Prisma based on the schema and is exposed as the db
object from the database
package in the monorepo.
This guide covers the basic operations of the database client, such as querying, creating, updating, and deleting records. To learn more about the Prisma client, check out the official documentation.
Querying records
To query records from the database, you can use the findMany
method on the Prisma client. This method accepts an object with optional where
, orderBy
, skip
, and take
fields to filter, order, and paginate the results.
Here is an example of querying all users from the database:
Creating records
To create a new record in the database, you can use the create
method on the Prisma client.
Updating records
To update an existing record in the database, you can use the update
method on the Prisma client.
Deleting records
To delete a record from the database, you can use the delete
method on the Prisma client.