@cocrepo/schema
v0.3.6
Published
Shared schema, DTOs and entities for the core project
Readme
@shared/prisma
Shared Prisma schema and types for the core project.
Features
- Centralized Prisma schema management
- Type-safe database client
- Common database utilities
- Shared database types across backend services
Installation
This package is part of the workspace and is automatically available to other packages.
Usage
Basic Usage
import { PrismaClient, prisma } from "@shared/prisma";
// Use the default instance
const users = await prisma.user.findMany();
// Or create your own instance
const customClient = new PrismaClient();Type Exports
import type { User, CreateInput, UpdateInput } from "@shared/prisma";
// Use generated Prisma types
type UserData = User;
// Use utility types
type CreateUserInput = CreateInput<User>;
type UpdateUserInput = UpdateInput<User>;Scripts
pnpm run build- Build the packagepnpm run dev- Build in watch modepnpm run generate- Generate Prisma clientpnpm run db:push- Push schema to databasepnpm run db:studio- Open Prisma Studiopnpm run db:migrate- Create and apply migrationspnpm run db:seed- Seed the database
Schema Organization
The Prisma schema is organized into multiple files:
schema/schema.prisma- Main configurationschema/user.prisma- User-related modelsschema/role.prisma- Role and permission modelsschema/space.prisma- Space-related modelsschema/file.prisma- File management modelsschema/core.prisma- Core business models
Environment Variables
Required environment variables:
DATABASE_URL- PostgreSQL connection stringDIRECT_URL- Direct PostgreSQL connection string (optional)
