dependabot[bot] on npm_and_yarn
dependabot[bot] on npm_and_yarn
Bump marked from 0.3.6 to 4.0.1… (compare)
ViewProjectionin v4 (on the latest version), it seems that you have to use
Identity<T>(o => o....)along with
ProjectEvent<T>otherwise the projection will never get the event. Going through as much sample code as I could find, it seems like at one point this was possible (?) but perhaps not.
ViewProjectionto get all the events of a certain type even if there is no "identity" correlation? For instance, let's say that tax rates have changed. There is no direct link between that
TaxChangedevent and a customer dashboard projection (e.g. no
OrderIdto use), but the dashboard now needs to show that upcoming orders will cost more.
TaxChangedevent to each
Customerstream and then they can deal with it.
On a slightly related note, then. If I wanted to create the
CustomerDashboard "projection" manually by applying events from a
Customer stream and a
Tax stream (vastly simplifying things here), is there anything in Marten I can leverage?
Currently, it seems I would
FetchStreamfor both streams and combine them into a list of
IEvent. Apply each event to
Apply(IEvent @event)method in
CustomerDashboardwould look at the generic type argument , and cast
@event.Dataappropriately, then call
Apply(TaxChanged @event)for example.
It seems like that second bullet point is probably already taken care of somewhere in Marten, and I think this paragraph hints at it - is that where I should continue exploring? (from https://martendb.io/documentation/events/projections/)
Aggregates Across Multiple Streams
Example coming soon, and check Jeremy's blog for a sample soon.
It's possible currently by using either a custom IProjection or using the existing aggregation capabilities with a custom IAggregateFinder<T>, where T is the projected view document type.
I'm not worried (yet) about storing the projection if that makes any difference.
ViewProjectionhow to determine the view identity in every single call to
ProjectEvent(). In V4 you accomplish that through the
SetIdentity()method instead, with the assumption/guidance being that you’d make that much easier by using some kind of common interface on the events to expose the view id and you’d only have to do that once as opposed to doing that event type by event type in the V3 and before ViewProjection.
AggregateStreamAsync()that just applies the projection in memory against the current events
ViewProjectiondoes assume that whatever information you need to determine the identity of the aggregate is available in only the event itself. It admittedly doesn’t support any kind of scenario where you’d have to query into the database or another service to find the actual view identity. We could try to add that to
ViewProjection, but it’d be hard to do that in a way that was actually effecient to avoid hammering the database with little calls. That was actually the goal of #1628, to allow the async projections to look ahead through events coming in and make batched queries to fetch related data instead of doing an N+1 loop event by event the way it admittedly has to today.
IProjectionfor scenarios like @jedidja ’s where they can easily write more efficient code for their one off scenario.
Looking at #1680, just so I don't start down the wrong path, here are bunch of total newbie questions (apologies in advance) based on a random-ish walk through
EventStore and friends.
I see that
QueryAllRawEventData() a new method to add?
The work item title says "...against any IQueryable<IEvent>". Is that really
If the answer to 2 is yes, then would the implementation for this go in
Happy to work on a PR for this if anyone can give a quick high-level overview of which area of the code I should poke at :) Or, if questions like this are better asked in the work item comments, I can move the discussion there. I know it's not a "big story" for @jeremydmiller but all brand-new stuff for me heh.
Hi, I've started transition to v4 in our production project. As for now almost everything is working. I just miss one feature we had in the past and used extensively. I saw similar discussion recently here.
ViewProjection<TDoc, TId> used to have an option to apply one event to multiple documents via
ProjectEvent(Func<IDocumentSession, TEvent, IList<Guid>> idSelector, (...)) or something similar. Now it's missing, and all I have is Identity<TEvent>(Func<TEvent, TId> identityFunc) which only allows to select one Id to be updated.
Our use is similar to: https://0bin.net/paste/pEbbcvtw#m6caJOCjZbQf+-UT+5iSzF3xtDe5rY8KIkmbEmYYhc/ (sorry for raw form)
How can I replicate that behaviour in v4? I wouldn't like to migrate any data since it's already on production and spans trough gigabytes of data... Just by looking at the code and JasperFx/marten#1610 (and linked issues), I see some options (I don't know if they are valid):
Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token);and other methods from base class and provide own implementations (I see this as dangerous)
FanOut()effectively makes a collection of objects within a single event look like events to the
FanOut()here would work if it had an option to pass in an
IQuerySessionto do your query. What it would effectively do is “explode” the incoming event into a new virtual event for each manufacturer. After that, the
ViewProjectionmechanics are unchanged and you’d get all the optimizations built into the V4 aggregations
FanOut()wouldn’t take very long.