use of org.mongodb.morphia.query.UpdateResults in project morphia by mongodb.
the class TestUpdateOps method testRemoveWithNoData.
@Test
@Ignore("mapping in WriteResult needs to be resolved")
public void testRemoveWithNoData() {
DumbColl dumbColl = new DumbColl("ID");
dumbColl.fromArray = singletonList(new DumbArrayElement("something"));
DumbColl dumbColl2 = new DumbColl("ID2");
dumbColl2.fromArray = singletonList(new DumbArrayElement("something"));
getDs().save(asList(dumbColl, dumbColl2));
UpdateResults deleteResults = getDs().update(getDs().find(DumbColl.class).field("opaqueId").equalIgnoreCase("ID"), getAds().createUpdateOperations(DumbColl.class, new BasicDBObject("$pull", new BasicDBObject("fromArray", new BasicDBObject("whereId", "not there")))));
getDs().update(getDs().find(DumbColl.class).field("opaqueId").equalIgnoreCase("ID"), getAds().createUpdateOperations(DumbColl.class).removeAll("fromArray", new DumbArrayElement("something")));
}
Aggregations