public UpdateOperations<T> removeAll(String fieldExpr, Object value) { if (value == null) throw new QueryException("Value cannot be null."); // Object dbObj = mapr.toMongoObject(value); add(UpdateOperator.PULL, fieldExpr, value, true); return this; }
public UpdateOperations<T> removeAll(String fieldExpr, List<?> values) { if (values == null || values.isEmpty()) throw new QueryException("Value cannot be null or empty."); // List<Object> vals = toDBObjList(values); add(UpdateOperator.PULL_ALL, fieldExpr, values, true); return this; }
public UpdateOperations<T> add(String fieldExpr, Object value, boolean addDups) { if (value == null) throw new QueryException("Value cannot be null."); // Object dbObj = mapr.toMongoObject(value, true); add((addDups) ? UpdateOperator.PUSH : UpdateOperator.ADD_TO_SET, fieldExpr, value, true); return this; }
public UpdateOperations<T> inc(String fieldExpr, Number value) { if (value == null) throw new QueryException("Value cannot be null."); add(UpdateOperator.INC, fieldExpr, value, false); return this; }
public UpdateOperations<T> set(String fieldExpr, Object value) { if (value == null) throw new QueryException("Value cannot be null."); // Object dbObj = mapr.toMongoObject(value, true); add(UpdateOperator.SET, fieldExpr, value, true); return this; }
public Query<T> order(String condition) { if (snapshotted) throw new QueryException("order cannot be used on a snapshotted query."); //reset order if (condition == null || condition.trim().isEmpty()) sort = null; sort = parseFieldsString(condition, clazz, this.ds.getMapper(), this.validateName); return this; }
public UpdateOperations<T> addAll(String fieldExpr, List<?> values, boolean addDups) { if (values == null || values.isEmpty()) throw new QueryException("Values cannot be null or empty."); // List<?> convertedValues = (List<?>)mapr.toMongoObject(values, true); if (addDups) add(UpdateOperator.PUSH_ALL, fieldExpr, values, true); else add(UpdateOperator.ADD_TO_SET_EACH, fieldExpr, values, true); return this; }
private T addGeoCrit(FilterOperator op, Object val, Map<String, Object> opts) { if (not) throw new QueryException("Geospatial queries cannot be negated with 'not'."); target.add(new GeoFieldCriteria(query, field, op, val, validateName, false, opts)); return target; }
protected void add(UpdateOperator op, String f, Object value, boolean convert) { if (value == null) throw new QueryException("Val cannot be null");
throw new QueryException("sorting is not allowed for updates."); if (qi.getOffset() > 0) throw new QueryException("a query offset is not allowed for updates."); if (qi.getLimit() > 0) throw new QueryException("a query limit is not allowed for updates.");
/** * @param query * @param wc * @param <T> * @return */ public <T> WriteResult delete(Query<T> query, WriteConcern wc) { DBCollection dbColl = query.getCollection(); //TODO remove this after testing. if (dbColl == null) dbColl = getCollection(query.getEntityClass()); WriteResult wr; if (query.getSortObject() != null || query.getOffset() != 0 || query.getLimit() > 0) throw new QueryException("Delete does not allow sort/offset/limit query options."); if (query.getQueryObject() != null) if (wc == null) wr = dbColl.remove(query.getQueryObject()); else wr = dbColl.remove(query.getQueryObject(), wc); else if (wc == null) wr = dbColl.remove(new BasicDBObject()); else wr = dbColl.remove(new BasicDBObject(), wc); throwOnError(wc, wr); return wr; }
throw new QueryException("mapReduce does not allow the offset/retrievedFields query options.");