Comments (1)
I found another way doing this. In fact I have all necessary informations in the .UpdateFromContext()
-Method. So in there I can perform a standard MongoDb-Update.
The only thing I could not figure out, how to return an "empty" Update operation, so I do an additional call to update.Set()
. Maybe someone has a hint how to solve this better?
On<ItemQuantityChanged>(
builder =>
{
return builder
.UpdateOne
.Filter(
(ctx, filter) => filter.ElemMatch(
pickupstation => pickupstation.Shelves,
Builders<Shelve>.Filter.Eq(a => a.Reservation!.Id, ctx.Stream.GetId())
)
)
.UpdateFromContext(
async (ctx, update) =>
{
var updateDefinition = Builders<PickupstationDocument>
.Update
.Set("Shelves.$[shelve].Reservation.Articles.$[article].Quantity", ctx.Message.NewQuantity);
var arrayFilterDefinitions = new List<ArrayFilterDefinition>
{
new BsonDocumentArrayFilterDefinition<BsonDocument>(
new BsonDocument("shelve.Reservation.Id", ctx.Stream.GetId())
),
new BsonDocumentArrayFilterDefinition<BsonDocument>(
new BsonDocument("article.Name", ctx.Message.ArticleName)
)
};
MongoDB.Driver.UpdateResult updateResult = await Collection
.UpdateOneAsync(
x => x.Shelves.Any(shelve => shelve.Reservation != null && shelve.Reservation!.Id == ctx.Stream.GetId()),
updateDefinition,
new UpdateOptions
{
ArrayFilters = arrayFilterDefinitions
}
)
.ConfigureAwait(true);
return update.Set(x => x.LastChanged, ctx.Created);
}
);
}
);
Nevertheless the original problem is fixed.
from eventuous.
Related Issues (20)
- With the SQL Server event store, event handlers are sometimes called twice for each event HOT 4
- Health check stays "healthy" even if Event Handler throws an exception HOT 5
- Transient error drops the subscription. (Connection reset by peer) HOT 6
- Add subscription drop/resubscribe tests HOT 1
- Add subscription measure for RDBMS subs HOT 1
- Error at schema initialization (PostgresException: '42704: type public.stream_message[] does not exist) HOT 1
- Eventuous should always return `Result<TState>` HOT 2
- Does it make sense to keep `Aggregate` without state? HOT 9
- Preserve original exception stacktrace in command service HOT 1
- Enable custom configuration of NpgsqlDataSourceBuilder when using AddEventuousPostgres HOT 1
- DuplicateTypeException in CommandService HOT 11
- "Can not start an Activity that was already started" in BaseProducer
- Memory leak (CancellationTokenSource) in AsyncHandlingFilter HOT 1
- Use source generator for type mapping HOT 1
- Use source generator for mapping HTTP API to command handlers HOT 2
- Persistent subscriptions are not invoking the FailureHandler
- Avoid using default type mapper in producer extensions HOT 2
- ObjectResult is stacked twice in case of ProblemDetails and always returns BadRequest HOT 1
- OptimisticConcurrencyException is not recognized HOT 7
- Ability to specify projected collection name distinct from projected document type. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventuous.