Prisma Domain Mapper Generator

Community

Isolate domain from DB, map entities with precision.

AuthorRomualdP
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill solves the problem of coupling the Domain Layer to the database technology (Prisma) by generating robust bidirectional mappers, ensuring the core business logic remains pure, testable, and independent of persistence details.

Core Features & Use Cases

  • Bidirectional Mapping: Creates static toDomain() (Prisma Model → Domain Entity) and toPrisma() (Domain Entity → Prisma Input) methods for seamless data conversion.
  • Value Object Reconstruction: Guides on correctly reconstructing Value Objects from primitive database values when mapping to the domain.
  • Relation Handling: Provides patterns for mapping 1-to-1 and 1-to-many relations, including handling nullable fields and nested creates.
  • Use Case: When fetching a Club from the database, the ClubRepository uses ClubMapper.toDomain() to convert the raw Prisma Club model into a rich Club domain entity with its associated ClubName Value Object, ready for business logic.

Quick Start

To create a mapper, define static toDomain(prismaModel: PrismaModel): DomainEntity and static toPrisma(domainEntity: DomainEntity): PrismaCreateInput methods. Ensure toDomain() reconstructs Value Objects and toPrisma() extracts primitives.

Dependency Matrix

Required Modules

@prisma/client

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: Prisma Domain Mapper Generator
Download link: https://github.com/RomualdP/hoki/archive/main.zip#prisma-domain-mapper-generator

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository