知识卡片
命令可以返回业务结果
CQRS不禁止命令返回数据。调用者至少需要知道成功、验证失败或技术失败;命令还可返回刚修改的结果供界面或后续流程使用,减少额外查询。返回内容必须来自强一致命令模型,不能假设最终一致的读模型已立即刷新。
相关:[[CQRS分开写入与读取]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 架构模式 · 查看原书依据
A command should always let the caller know whether it has succeeded or failed. If it has failed, why did it fail? Was there a validation or technical issue? The caller has to know how to fix the command. Therefore, a command can—and in many cases should—return data; for example, if the system’s user interface
参考来源
- 位置:《Learning Domain-Driven Design》第8章《架构模式》(来源项目:book-sources;源文件:extracted/Learning Domain-Driven Design/_epub-src/OEBPS/ch08.html)
- 结论依据:原文围绕本卡所述机制给出定义、适用条件及相关取舍,以下摘录为直接依据。
- 原始内容:A command should always let the caller know whether it has succeeded or failed. If it has failed, why did it fail? Was there a validation or technical issue? The caller has to know how to fix the command. Therefore, a command can—and in many cases should—return data; for example, if the system’s user interface