repositories-and-data-access
Implement repository interfaces for data persistence and abstraction over database operations using Bun ORM.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-04
- Stars
- ★ 41
- Forks
- 0
01 前言 Front Matter
- name
- repositories-and-data-access
- description
- Implement repository interfaces for data persistence and abstraction over database operations using Bun ORM.
02 资源文件 1
- 脚本examples/bun_todo_repository.go2.0 KB
03 SKILL.md 正文
Repositories & Data Access
When to use this skill
- Create data access layer abstractions for entities
- Implement Bun-based repositories for database operations
- Define repository interfaces that services depend on
- Add transaction support (WithTx) to repositories
Key principles
- Interface segregation: One repository interface per domain model
- Bun ORM: Use Bun for type-safe database operations
- Transaction support: Every repository implements
WithTx(tx bun.IDB) - Context-aware: All operations accept
context.Context - No business logic: Repositories only handle CRUD; logic lives in services
Pattern
Repositories are data access only:
- Define interface with CRUD operations (Create, GetByID, Update, Delete)
- Implement with Bun in
bun_*.gofiles - Accept
bun.IDBat construction (not concrete*bun.DB) - Return interfaces from constructors
- Missing records return
nil, nilfor single queries; empty slice for batch queries
Example
See examples/bun_todo_repository.go for:
- ITodoRepository interface definition
- bunTodoRepository Bun implementation
- CRUD and batch query patterns
Common mistakes
- Returning errors for missing records (use nil instead)
- Forgetting
WithTx()method - Putting business logic in repositories
- Not passing context to Scan/Exec
- Repository-to-repository calls instead of service orchestration
References
04 同仓库更多 Skills
typst
Typst document creation and package development. Use when: (1) Working with .typ files, (2) User mentions typst, typst.toml, or typst-cli, (3) Creating or using Typst packages, (4) Developing document templates, (5) Converting Markdown/LaTeX to Typst
shadcn
Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for "shadcn init", "create an app with --preset", or "switch to --preset".
handoff
Compact the current conversation into a handoff document for another agent to pick up.
grilling
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
grill-me
A relentless interview to sharpen a plan or design.
dont-waffle
Use this skill when answering questions, explaining concepts, writing technical responses, reviewing code, or helping with development tasks. Communicate in clear, simple, standard English. Keep answers concise and focused, remove unnecessary filler and repetition, explain technical ideas in plain language, and structure information so it is easy to read and understand. When showing code, present it clearly with enough context for the developer to understand what it does and where it belongs.