BasicDBObject fields = new BasicDBObject();
query.put(“productID”, 1);
query.put("@type”, 2);
BasicDBObject allQuery = new BasicDBObject();
DBCursor cursor = mongoDatasource.getMongoDatasource().find(allQuery, fields);
while(cursor.hasNext()) {
DBObject document = cursor.next();
System.out.println(document);
}
Result:
{ “_id” : { “$oid” : “56c6c9e0612eb61e88166894”} , “@type” : “Product” , “productID” : “1”}
BasicDBObject query = new BasicDBObject().append(“productID”, String.valueOf(productId));
DBObject listItem = new BasicDBObject(“offers.offers”, newValue);
BasicDBObject update = new BasicDBObject().append(“$push”, listItem);
mongoDatasource.getMongoDatasource().update(query, update, false, true);