marten icon indicating copy to clipboard operation
marten copied to clipboard

querying / filtering events by type

Open schmitch opened this issue 4 years ago • 3 comments

currently I'm working on a small reporting tool that will output some of our events (create and change events for a specific type) into a csv specific by a start time and end time.

Unfortunatly via QueryRawEventDataOnly it's not possible to filter by multiple types. and QueryAllRawEvents does not expose the type parameter.

At the moment the only thing it might be possible would be to do client side filtering:

var events = await session.Events
   .QueryAllRawEvents()
   .Where(t => t.Timestamp >= firstDayOfMonth && t.Timestamp < firstDayOfNextMonth)
   .ToListAsync();
            
events.Where(t => t is Event<TenantCreateEvent> || t is Event<TenantChangeEvent>).ToList()

it would be at least great to expose the type param to IEvent

schmitch avatar Dec 04 '20 11:12 schmitch

Hmm, not knowing the application, have you tried or considered just going with projections? E.g. see the example https://martendb.io/documentation/events/projections/projectionbyeventtype/ that projects by a time window.

jokokko avatar Dec 04 '20 15:12 jokokko

And I still like this idea, but I'm unilaterally kicking it back to 4.1

jeremydmiller avatar Mar 01 '21 22:03 jeremydmiller

Maybe support query by interface ? see https://github.com/JasperFx/marten/issues/623

mdissel avatar Mar 02 '21 07:03 mdissel