implement-dao

Automate SQLDelight-backed DAO creation with interface/implementation separation and test fakes.

219|41|Updated Feb 21, 2024
One-click install
npx skills add https://github.com/proto-at-block/bitkey --skill implement-dao
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implement-dao
Source: https://github.com/proto-at-block/bitkey/tree/main/app/ai-rules/skills/implement-dao
Command: npx skills add https://github.com/proto-at-block/bitkey --skill implement-dao

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

DAOs are often implemented inconsistently across modules, leading to duplicated code, fragile tests, and hard maintenance. This Skill standardizes implementing a SQLDelight-backed DAO with a clean interface/implementation separation, proper transaction handling, and test-friendly fakes.

Core Features & Use Cases

  • Interface and implementation live in separate modules with a clear boundary.
  • Transaction-aware operations and proper error handling via DbError.
  • Fake in-memory storage with reset() for reliable tests.

Quick Start

Create the SQLDelight .sqldelight file, implement the interface and impl in the :impl module, annotate the impl with @BitkeyInject(AppScope::class), and add a fake in the :fake module with reset().

Frequently Asked Questions about implement-dao

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

FAQPage Schema
How do I implement a DAO with SQLDelight in a Kotlin Android project?

To implement a DAO with SQLDelight, create a .sqldelight file, define the interface and implementation in separate modules, annotate the impl with @BitkeyInject(AppScope::class), and add a fake in the :fake module. This standardizes boundaries and transaction handling.

What's the best way to structure SQLDelight DAOs across multiple modules?

The best way to structure SQLDelight DAOs is separating the interface and implementation into distinct modules with a clear boundary. This enforces interface/implementation separation, transaction-aware operations, and DI integration for maintainable Android code.

How do I create testable fakes for SQLDelight DAOs?

To create testable fakes for SQLDelight DAOs, implement a fake in-memory storage class in the :fake module with a reset() method. This provides reliable, isolated testing by allowing test doubles to be reset between test runs.

Does this DAO approach support dependency injection in Kotlin?

Yes, this DAO approach supports dependency injection in Kotlin by annotating the implementation class with @BitkeyInject(AppScope::class). This integrates the SQLDelight-backed DAO directly into your DI graph for proper transactional usage.

How does this DAO implementation handle database transactions and errors?

This DAO implementation handles database transactions and errors by enforcing transaction-aware operations and proper error handling via DbError. This ensures consistent transactional boundaries and safe error propagation across your SQLDelight database operations.

Why do I need to separate my DAO interface from its SQLDelight implementation?

You need to separate your DAO interface from its SQLDelight implementation to prevent duplicated code, ensure consistent transaction handling, and enable test-friendly fakes. This clear module boundary isolates database logic for easier maintenance.