Eventuous.Projections.MongoDB
0.6.0-rc.4
See the version list below for details.
dotnet add package Eventuous.Projections.MongoDB --version 0.6.0-rc.4
NuGet\Install-Package Eventuous.Projections.MongoDB -Version 0.6.0-rc.4
<PackageReference Include="Eventuous.Projections.MongoDB" Version="0.6.0-rc.4" />
paket add Eventuous.Projections.MongoDB --version 0.6.0-rc.4
#r "nuget: Eventuous.Projections.MongoDB, 0.6.0-rc.4"
// Install Eventuous.Projections.MongoDB as a Cake Addin #addin nuget:?package=Eventuous.Projections.MongoDB&version=0.6.0-rc.4&prerelease // Install Eventuous.Projections.MongoDB as a Cake Tool #tool nuget:?package=Eventuous.Projections.MongoDB&version=0.6.0-rc.4&prerelease
Eventuous MongoDB projections
This package adds MongoDB projections to applications built with Eventuous.
There are two main components provided by this package:
MongoCheckpointStore
, implementsICheckpointStore
MongoProjection
, implementsIEventHandler
Using checkpoint store
You can register MongoCheckpointStore
so it will be used by all subscriptions that need to store checkpoints (normally, EventStoreDB catch-up subscriptions).
services.AddSingleton<ICheckpointStore, MongoCheckpointStore>();
It will add a checkpoint
collection to your Mongo database. Each subscription will have its own checkpoint document. The document id would be the subscription id.
Make sure to use unique subscription ids across different applications if they use the same Mongo database.
Using projections
Create your own projection class that inherits MongoProjection<T>
abstract class.
Here, T
is the document type, which must be a record. Your document type should inherit from ProjectedDocument
record.
Use the On<TEvent>
function to register event projection handlers:
public class ProjectWithTasksProjection : MongoProjection<ProjectWithTasks> {
public ProjectWithTasksProjection(
IMongoDatabase database,
ILoggerFactory? loggerFactory
) : base(database, QuerySubscription.Id, loggerFactory) {
On<V1.ProjectRegistered>(
evt => evt.ProjectId,
(evt, update) => update.SetOnInsert(x => x.ProjectName, evt.Name)
);
On<V1.TaskCreated>(
evt => evt.ProjectId,
(evt, update) => update.AddToSet(
x => x.Tasks,
new ProjectTaskRecord(evt.TaskId, evt.Description)
)
);
}
}
There's an overload for On<TEvent>
that gives you direct access to the consume context, so you can have more advanced operations.
On<V1.ProjectRegistered>(ctx => { ... });
The function provided as an argument for On
in this case needs to return ValueTask<Operation<T>>
.
To make things easier, we provide a function called UpdateOperationTask
.
The UpdateOperationTask
function has two overloads.
The one used in the example allows passing the document id as the first argument.
Another overload allows specifying a custom filter as (filter, evt) => filter.Eq(x => x.Field == evt.Value)
.
You can also use the UpdateOperation
, which allows you to perform asynchronous operations inside the update function.
There is also a handler registration function for building updates asynchronously called OnAsync
, which works similar t On
:
OnAsync<V1.ProjectRegistered>(
evt => evt.ProjectId,
async (evt, update) => update.SetOnInsert(
x => x.ProjectName,
await getExternalData(evt.Name)
)
);
You also have an option of not using pre-registered typed handlers by overriding the GetUpdate
function.
By default it returns NoOp
, so if you override it, don't call base.GetUpdate
. Eventuous will only call GetUpdate
if there's no registered handler for a received event.
The GetUpdate
function must return an instance of the Operation<T>
record wrapped in ValueTask
.
UpdateOperation
and UpdateOperationTask
return ValueTask<UpdateOperation<T>>
. You can use one of the supplied record types:
UpdateOperation<T>
- includes a filter and an update operationCollectionOperation<T>
- allows executing any operation on the collectionOtherOperation<T>
- allows executing anything as it will be just awaited
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Eventuous.Subscriptions (>= 0.6.0-rc.4)
- MongoDB.Driver (>= 2.12.2)
-
net5.0
- Eventuous.Subscriptions (>= 0.6.0-rc.4)
- MongoDB.Driver (>= 2.12.2)
-
net6.0
- Eventuous.Subscriptions (>= 0.6.0-rc.4)
- MongoDB.Driver (>= 2.12.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Eventuous.Projections.MongoDB:
Package | Downloads |
---|---|
Eventuous.Connector.EsdbMongo
Eventuous connector between EventStoreDB and other things |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.15.1 | 468 | 11/7/2024 |
0.15.0 | 1,450 | 9/10/2024 |
0.15.0-rc.3 | 481 | 8/15/2024 |
0.15.0-rc.2 | 701 | 7/19/2024 |
0.15.0-rc.1 | 414 | 6/27/2024 |
0.15.0-beta.10 | 1,042 | 2/11/2024 |
0.15.0-beta.8 | 470 | 11/18/2023 |
0.15.0-beta.7 | 75 | 11/17/2023 |
0.15.0-beta.6 | 799 | 10/4/2023 |
0.15.0-beta.5 | 3,511 | 8/28/2023 |
0.15.0-beta.4 | 338 | 8/22/2023 |
0.15.0-beta.3 | 74 | 8/21/2023 |
0.15.0-beta.2 | 80 | 8/21/2023 |
0.15.0-beta.1 | 363 | 8/21/2023 |
0.14.0 | 21,961 | 2/10/2023 |
0.13.4-alpha.0.1 | 117 | 2/10/2023 |
0.13.3 | 838 | 2/1/2023 |
0.13.2 | 284 | 2/1/2023 |
0.13.1 | 1,379 | 1/14/2023 |
0.13.0 | 746 | 1/10/2023 |
0.12.0 | 734 | 10/6/2022 |
0.11.4 | 399 | 9/30/2022 |
0.11.3 | 440 | 9/27/2022 |
0.11.2 | 552 | 9/23/2022 |
0.11.1 | 440 | 9/23/2022 |
0.11.0 | 432 | 9/20/2022 |
0.10.6 | 504 | 9/9/2022 |
0.10.5 | 449 | 8/25/2022 |
0.10.4 | 414 | 8/22/2022 |
0.10.3 | 425 | 8/21/2022 |
0.10.2 | 1,562 | 7/20/2022 |
0.10.1 | 453 | 7/20/2022 |
0.10.0 | 458 | 7/17/2022 |
0.9.1 | 462 | 6/24/2022 |
0.9.0 | 451 | 6/15/2022 |
0.8.4 | 494 | 5/18/2022 |
0.8.3 | 503 | 5/11/2022 |
0.8.2 | 434 | 5/11/2022 |
0.8.1 | 494 | 5/8/2022 |
0.8.0 | 430 | 4/25/2022 |
0.7.1 | 497 | 4/21/2022 |
0.7.0 | 458 | 4/13/2022 |
0.6.2 | 444 | 3/28/2022 |
0.6.1 | 443 | 3/11/2022 |
0.6.0 | 1,227 | 2/21/2022 |
0.6.0-rc.8 | 246 | 11/27/2021 |
0.6.0-rc.7 | 2,425 | 11/25/2021 |
0.6.0-rc.6 | 3,277 | 11/25/2021 |
0.6.0-rc.5 | 3,001 | 11/25/2021 |
0.6.0-rc.4 | 4,937 | 11/24/2021 |
0.6.0-rc.3 | 4,850 | 11/23/2021 |
0.6.0-rc.2 | 1,103 | 11/20/2021 |
0.6.0-rc.1 | 166 | 11/19/2021 |
0.5.15 | 5,716 | 10/12/2021 |
0.5.14 | 798 | 10/10/2021 |
0.5.13 | 312 | 10/10/2021 |
0.5.12 | 367 | 10/10/2021 |
0.5.11 | 382 | 10/10/2021 |
0.5.10 | 382 | 10/10/2021 |
0.5.9 | 519 | 10/9/2021 |
0.5.8 | 331 | 10/9/2021 |
0.5.7 | 325 | 10/9/2021 |
0.5.6 | 310 | 10/9/2021 |
0.5.5 | 367 | 10/9/2021 |
0.5.4 | 391 | 10/9/2021 |
0.5.3 | 372 | 10/9/2021 |
0.5.2 | 415 | 10/9/2021 |
0.5.1 | 342 | 10/6/2021 |
0.5.0 | 424 | 10/5/2021 |
0.4.7 | 884 | 8/20/2021 |
0.4.6 | 448 | 8/6/2021 |
0.4.5 | 734 | 6/4/2021 |
0.4.4 | 1,163 | 5/25/2021 |
0.4.3 | 354 | 5/24/2021 |
0.4.2 | 369 | 5/24/2021 |
0.4.1 | 423 | 5/21/2021 |
0.4.0 | 371 | 5/21/2021 |
0.3.1 | 379 | 5/24/2021 |
0.3.0 | 337 | 5/12/2021 |
0.2.0 | 398 | 4/27/2021 |
0.1.1 | 392 | 4/9/2021 |
0.1.1-alpha.0.9 | 174 | 4/8/2021 |
0.1.1-alpha.0.7 | 172 | 4/8/2021 |
0.1.1-alpha.0.6 | 174 | 4/8/2021 |
0.1.1-alpha.0.5 | 160 | 3/29/2021 |
0.1.0 | 409 | 3/25/2021 |
0.0.0-alpha.0.41 | 152 | 3/24/2021 |
0.0.0-alpha.0.31 | 184 | 3/24/2021 |
0.0.0-alpha.0.22 | 193 | 3/24/2021 |
0.0.0-alpha.0.21 | 199 | 3/23/2021 |
0.0.0-alpha.0.20 | 205 | 3/23/2021 |
0.0.0-alpha.0.19 | 204 | 3/23/2021 |
0.0.0-alpha.0.18 | 154 | 3/17/2021 |
0.0.0-alpha.0.17 | 148 | 3/17/2021 |
0.0.0-alpha.0.16 | 148 | 3/17/2021 |
0.0.0-alpha.0.15 | 161 | 3/17/2021 |
0.0.0-alpha.0.14 | 161 | 3/17/2021 |
0.0.0-alpha.0.13 | 181 | 3/16/2021 |
0.0.0-alpha.0.12 | 187 | 3/10/2021 |
0.0.0-alpha.0.11 | 219 | 3/10/2021 |
0.0.0-alpha.0.10 | 216 | 3/10/2021 |
0.0.0-alpha.0.9 | 224 | 3/8/2021 |
0.0.0-alpha.0.8 | 166 | 3/8/2021 |