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.