Sometimes you need to create a new collection on the fly from a MongoDB aggregation pipeline. Fortunately, you can easily do that with MongoTemplate using the addToSet operation.
Did you know that you can put conditionals in your MongoDB aggregation pipelines? Even better: you can do so within your Spring Boot application using MongoTemplate.
It's often the case that documents in a MongoDB collection include arrays of child documents. And sometimes you want to "unwind" those arrays to create one parent document for each child element.