知识卡片
仓储接口隔离存储细节
仓储模式向业务层提供获取、添加、删除等近似内存集合的接口,由仓储将这些操作转换为具体存储命令。业务代码因此依赖所需的数据操作契约,而不直接依赖 ORM 模型或 SQL。更换存储实现仍可能需要调整适配器,但不应迫使核心业务规则一起改变。参见 [[端口定义技术无关接口]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 7 章《Service implementation patterns for microservices》(源文件:_epub-src/OEBPS/Text/07.htm)
- 结论依据:原文定义仓储为近似内存列表的稳定接口,负责把获取、添加、删除等操作转换为数据库专有命令,并用于隔离业务层。
- 原始内容:The repository takes care of managing interactions with the database and provides a consistent interface to our components, regardless of the database technology used. This allows us to change the database system without having to change our core business logic.