You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EntryTitle, Tag, CategoryTitle and CategoryId are VALUE OBJECTs via simple String wrapping struct. Both ENTITY don't have an id property as those are handled inside cqrs-es if I understand correctly.
Now I want to have 3 views:
The entries
The tags (the tags themselves, but also references to entries with that tag)
The categories (the categories themselves, but also references to entries with that category)
Implemention?
view "entries"
The entries view is 1:1 from the ENTITY Entry, so with cqrs-es I can use the GenericQuery with the Aggregate-implementing Entry. That's simple.
view "tags"
The tags view is derived from the ENTITY Entry and not considered an ENTITY in its own behalf. But rather I want to use that to find/index entries. So a struct implementing the View trait would use the tag itself as "view_id" and have one property: an array of Strings with the IDs of the Entity objects.
That I can't already build up using GenericQuery as it would use aggregate_id as view_id. I made new trait & struct to work around that
Generally speaking: It lets me decide which "view_id" is to be used for further processing inside the Query. Rest is taken more or less 1:1 from GenericQuery.
But here I have the problem, that not every event from the ENTITY Entry has all the details. I would need to have access on the Entity struct in that particular version/state to be able to correctly calculate the tags view. (e.g. I have a EntryRemoved event which should cause the view to drop ids referencing now removed Entry entities.)
Question 1: How to build projections/view which are derived from ENTITY, but are not 1:1 linked to an ENTITY?
or, Question 2: Can the EventEnvelope be extended to contain or return (from a method) the then actual, full Aggregate?
view "categories"
The categories in the view are also 1:1 related to the ENTITY Category. So GenericQuery it is. But (!) to be able to have that connection to the entries of that categories I would need to feed this view events from the ENTITY Entry.
Question 3: How to feed events from 2 ENTITY into one view?
Also question 1 above is relevant here, as I would need to also drop references to entries, if the ENTITY Entry is removed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm fairly new to DDD and CQRS, still reading through the "blue book". So maybe I choose the wrong approach. But what I want to achieve:
Situation / Goal
I have two ENTITY (both of them are aggregate roots) like
EntryTitle
,Tag
,CategoryTitle
andCategoryId
are VALUE OBJECTs via simple String wrappingstruct
. Both ENTITY don't have anid
property as those are handled insidecqrs-es
if I understand correctly.Now I want to have 3 views:
Implemention?
view "entries"
The entries view is 1:1 from the ENTITY
Entry
, so withcqrs-es
I can use theGenericQuery
with the Aggregate-implementingEntry
. That's simple.view "tags"
The tags view is derived from the ENTITY
Entry
and not considered an ENTITY in its own behalf. But rather I want to use that to find/index entries. So a struct implementing the View trait would use the tag itself as "view_id" and have one property: an array of Strings with the IDs of the Entity objects.That I can't already build up using
GenericQuery
as it would use aggregate_id as view_id. I made new trait & struct to work around thatGenerally speaking: It lets me decide which "view_id" is to be used for further processing inside the Query. Rest is taken more or less 1:1 from GenericQuery.
But here I have the problem, that not every event from the ENTITY
Entry
has all the details. I would need to have access on the Entity struct in that particular version/state to be able to correctly calculate the tags view. (e.g. I have aEntryRemoved
event which should cause the view to drop ids referencing now removedEntry
entities.)Question 1: How to build projections/view which are derived from ENTITY, but are not 1:1 linked to an ENTITY?
or, Question 2: Can the
EventEnvelope
be extended to contain or return (from a method) the then actual, full Aggregate?view "categories"
The categories in the view are also 1:1 related to the ENTITY
Category
. SoGenericQuery
it is. But (!) to be able to have that connection to the entries of that categories I would need to feed this view events from the ENTITYEntry
.Question 3: How to feed events from 2 ENTITY into one view?
Also question 1 above is relevant here, as I would need to also drop references to entries, if the ENTITY
Entry
is removed.Beta Was this translation helpful? Give feedback.
All reactions