I have a class that contains a List as one of the field. How can I update this field.
Found an example for updating a field
BasicDBObject newDocument3 = new BasicDBObject().append("$set", new
BasicDBObject().append("type", "dedicated server"));
collection.update(new BasicDBObject().append("hosting", "hostA"), newDocument3);
From link -> http://www.mkyong.com/mongodb/java-mongodb-update-document/
So this is what I have tried
BasicDBObject objectUpdateCommand = new BasicDBObject("$push", new
BasicDBObject("someList", stringValue));
collection.update(new BasicDBObject().append("id", user.getId()).append("email",
user.getEmail()), objectUpdateCommand);
Result: No change.
What am I missing?
Tried on shell and it worked [I know its not matching all the ids but it works for test purpose]
db.user.update( { Id: 'yourid'}, {$push: { someList: 'appendNewValue'} } )
_idinstead ofid