public Class Customer{
private long id;
private String name;
private String companyName;
private List<Environment> environment = new ArrayList<>();
}
public Class Environment{
private int clusterid;
private string clusterName
}
My Collection in Mongo DB
{
"id":1,
"name":"xyz",
"companyName":"abc",
"environment":[
{
"clusterid":2,
"clusterName":"qwe"
},
{
"clusterid":6,
"clusterName":nme"
}
]
}
want to update environment List of index 1 with returning whole environment List. How do I do this with spring boot? I want to update particular index of list fetching other too in the collection .
public int updateEnv(Customer customer) {
Query query = new Query();
query.addCriteria(Criteria.where("id").is(customer.getid()));
Update update = new Update();
update.set("environment", customer.getEnvironment());
return mongoUtil.update(query, update, Customer.class);
}
This query updating the whole environment List with the value in the list instead of at particular index. Please guide about positional operator .How to do this with positional operator in java