在CQRS的Write Side上从数据库读取数据 [英] Reading data from database on Write Side in CQRS

查看:90
本文介绍了在CQRS的Write Side上从数据库读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

解释CQRS的图通常将清楚地区分读写路径和单向数据流,例如在此示例中(来源:

Diagrams explaining CQRS usually will have clear separation of read and write paths and one-way data flow, like in this example (source :

问题:

我想澄清一下,

如果后端的Command执行需要数据库中的某些数据,则

If a Command execution in back-end requires some data from the database,

  • 写端"是否应具有从写数据库中读取的功能?
  • 还是应该完全依靠读取侧"进行读取?
  • 或者命令应该包含调用者提供的所有必需数据才能实现?

推荐答案

写面"应该具有从写数据库中读取的功能吗?

should a "write side" have some read capabilities from write database?

可能-加载将要运行命令的实体的最直接的方法是从写入数据库"中读取其状态.例如,在事件源体系结构中,通常通过以下方式处理更新事件源实体的命令:从写入模型中加载该实体的历史记录,从该历史记录中为该实体重新补水,评估该命令,并将新的更改附加到该历史记录中.

Probably -- the most straight forward way to load the entity that is going to be running the command is by reading its state from the "write database". For instance, in event sourced architectures, a command to update an event sourced entity is typically handled by loading the history of that entity from the write model, rehydrating the entity from that history, evaluating the command, and appending new changes to the history.

读取有关不是 处理命令的实体的状态是另一回事-

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆