How to update first element in array object
My document is { _id: 1, age: "young", hobby: [ { vehicle: "car", velocity: "fast" }, { vehicle: "motorcycle", velocity: "fast" } ] } My goal is: when age became old, first hobby became "slow" but others remain "fast" My code is: mongoTemplate.updateFirst( Query.query(where("_id").is("1")), Update.update("age", "old") .set("hobby.$[elem].velocity", "slow") .filterArray(Criteria.where("elem").is(0)), "collection name") But it does not… Read More How to update first element in array object