📜  spring boot mongodb 更新子文档 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:39.761000             🧑  作者: Mango

代码示例1
final Query query = new Query(new Criteria().andOperator(
        Criteria.where("_id").is("id"),
        Criteria.where("listA").elemMatch(Criteria.where("_id").is("id"))
));
final Update update = new Update().addToSet("listA.$.listB", stuff).set("listA.$.thing", "thing");
final WriteResult wr = mongoOperations.updateFirst(query, update, "collectionName");