@anujsingh95/postmind-db
v1.0.0
Published
Shared database operations package for Postmind CLI and Web
Downloads
5
Maintainers
Readme
@postmind/db
Shared database operations package for Postmind CLI and Web applications.
Overview
This package provides a unified interface for database operations, ensuring consistency between the CLI and Web applications. It abstracts Prisma operations into service layers that can be used by both applications.
Installation
npm install @postmind/dbUsage
Basic Setup
import { prisma } from '@postmind/db';
import { CollectionService } from '@postmind/db/services/collections';
// Use the shared Prisma client
const collections = await prisma.collection.findMany();
// Or use the service layer
const collectionService = new CollectionService(prisma);
const allCollections = await collectionService.getCollections(userId, workspaceId);For CLI (with custom database URL)
import { initializePrisma } from '@postmind/db';
import { CollectionService } from '@postmind/db/services/collections';
const dbUrl = process.env.DATABASE_URL;
const prisma = initializePrisma(dbUrl);
const collectionService = new CollectionService(prisma);Services
CollectionService- Collection CRUD operationsRequestService- Request CRUD operationsEnvironmentService- Environment CRUD operationsWorkspaceService- Workspace CRUD operationsHistoryService- API history operationsMockServerService- Mock server operations
Development
# Generate Prisma client
npm run db:generate
# Run migrations
npm run db:migrate
# Build the package
npm run build