repository-patterns

Enforce repository patterns for data access and domain model mapping in Madoc TS.

57|15|Updated Nov 28, 2018
One-click install
npx skills add https://github.com/digirati-co-uk/madoc-platform --skill repository-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: repository-patterns
Source: https://github.com/digirati-co-uk/madoc-platform/tree/main/.agents/skills/repository-patterns
Command: npx skills add https://github.com/digirati-co-uk/madoc-platform --skill repository-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses inconsistent data access in Madoc TS repositories, preventing bugs from ad-hoc queries and ensuring reliable mapping to domain models.

Core Features & Use Cases

  • Query Reuse and Static Helpers: Leverage shared queries from src/database/queries for consistent SQL operations across repositories.
  • Domain Model Mapping: Extend BaseRepository to map raw rows to structured models like projects or updates.
  • Use Case: When adding a new feature to fetch project metadata, use this Skill to refactor the project-repository.ts with reusable mutations and proper mapping, reducing duplication in services/madoc-ts.

Quick Start

Use the repository-patterns skill to refactor the data access method in project-repository.ts for handling user permissions.

Frequently Asked Questions about repository-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I normalize raw database rows to domain models in TypeScript?

Normalize raw database rows to domain models in TypeScript by extending BaseRepository to map query results into structured models like projects or updates, ensuring consistent domain data structures.

What is the best way to reuse SQL queries across TypeScript repositories?

Reuse SQL queries across TypeScript repositories by leveraging shared static helpers from src/database/queries to execute consistent SQL operations and prevent ad-hoc query duplication across data access layers.

How do I add new data access methods to a Madoc TS repository?

Add data access methods to a Madoc TS repository by extending BaseRepository, reusing static query helpers from src/database/queries, and normalizing raw database results to structured domain models.

Why do ad-hoc database queries cause bugs in TypeScript services?

Ad-hoc database queries cause bugs in TypeScript services because inconsistent data access patterns lead to unreliable mapping to domain models, bypassing structured data boundaries and causing duplication.

Can I update service boundaries when refactoring database queries in Madoc?

Yes, you can update service boundaries when refactoring database queries in Madoc by enforcing repository pattern adherence to normalize data access and reduce duplication in services/madoc-ts.