Update with Aggregate Inside Mongo Transaction

Hi Team,

Can I run an update with aggregate pipleline inside transactions? Does java driver API provide support for this ?

Hi @Laks and welcome to the community!!

Yes, you can utilise the aggregate pipeline for update operations starting with MongoDB 4.2.
Please refer the Updates with Aggregation Pipeline documentation to learn more on operations which can be used for the update operation.

Please refer to the Java Driver API Documentations to learn more.

However, if you need further help, could you help with the following informations:

  1. Java Driver version
  2. Code snippet that you are have tried.

Let us know if you need any further assistance.


@Aasawari, Thanks for your message. Let me rephrase it this way,
I create a mongo client session as mentioned in https://www.mongodb.com/docs/manual/core/transactions/ and run an update (multi documents) with aggregation pipeline.

If update is successful, commit transaction. If there are errors, roll back the updates across all transactions.

Is this update with aggregation pipeline supported in Mongo 4.4 with Java Driver 4.5?