Using the Prisma client
Learn how to use the Prisma client to interact with the database.
The Prisma client is defined in the packages/database/src/client.ts file, which can be imported in your application to interact with the database.
The client is imported as db:
import { db } from '@kit/database';You can then use the client to interact with the database:
import { db } from '@kit/database';// Find all usersconst allUsers = await db.user.findMany();// Create a new organizationconst newOrganization = await db.organization.create({ data: { id: crypto.randomUUID(), name: 'New Organization', slug: 'new-organization', createdAt: new Date(), },});// Find user by emailconst user = await db.user.findUnique({ where: { email: 'user@example.com' },});// Update a userawait db.user.update({ where: { id: userId }, data: { name: 'Updated Name' },});// Delete a userawait db.user.delete({ where: { id: userId },});For more information on how to use the Prisma client, please refer to the Prisma documentation.