How to use the $each modifier in the following findAndModify query of a MongoTemplate?
I have tried to find it in the Spring Docs, but nothing.
answers is the key in Mongo which holds an array.
new answers is an array which items should be added to the answers in Mongo.
mongoOperations.findAndModify(
    Query.query(...),
    Update().push("answers", newAnswers)
)
You can try this:
Update update = new Update();
update.push("answers").each(newAnswers);
mongoOperations.findAndModify(
    Query.query(...),
    update
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With