跳到正文
cccskills
免费在 GitHub 公开

repositories-and-data-access

Implement repository interfaces for data persistence and abstraction over database operations using Bun ORM.

中文简介正在准备中。当前显示原文说明。

Authula/authula星标 273(GitHub 273 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(2)

  • SKILL.md1.9 KB
  • examples/bun_todo_repository.go2.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

  1. Interface segregation: One repository interface per domain model
  2. Bun ORM: Use Bun for type-safe database operations
  3. Transaction support: Every repository implements WithTx(tx bun.IDB)
  4. Context-aware: All operations accept context.Context
  5. 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_*.go files
  • Accept bun.IDB at construction (not concrete *bun.DB)
  • Return interfaces from constructors
  • Missing records return nil, nil for 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

  1. Returning errors for missing records (use nil instead)
  2. Forgetting WithTx() method
  3. Putting business logic in repositories
  4. Not passing context to Scan/Exec
  5. Repository-to-repository calls instead of service orchestration

References

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Wire dependencies using constructor-based dependency injection throughout services, repositories, and handlers.

中文简介正在准备中。当前显示原文说明。

Authula/authula2732026年10月24日 更新

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.

中文简介正在准备中。当前显示原文说明。

Authula/authula2732026年10月24日 更新

grill-me

免费

A relentless interview to sharpen a plan or design.

中文简介正在准备中。当前显示原文说明。

Authula/authula2732026年10月24日 更新

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.

中文简介正在准备中。当前显示原文说明。

Authula/authula2732026年10月24日 更新

Implement HTTP handlers that parse requests, invoke use cases, and format responses following REST conventions.

中文简介正在准备中。当前显示原文说明。

Authula/authula2732026年10月24日 更新

handoff

免费

Compact the current conversation into a handoff document for another agent to pick up.

中文简介正在准备中。当前显示原文说明。

Authula/authula2732026年10月24日 更新

查看 Authula 的全部技能

报告此技能的问题