POSTS

Java, Mongo - Update array element

(based on http://schema.org/Product schema)
<![CDATA[ private void update(String path, Object newValue, Integer productId, Integer retailerId) throws Exception { BasicDBObject query = new BasicDBObject(“productID”, String.valueOf(productId)) .append(“offers.offers.offerID”, String.valueOf(offerId))); BasicDBObject update = new BasicDBObject(“$set”, new BasicDBObject().append(“offers.offers.$.name”, newValue)); mongoDatasource.getMongoDatasource().update(query, update, false, true); } ]]>
SyntaxHighlighter.highlight();