@Override protected DBCursor<T> put(String field, String op, Object value) { checkExecuted(); return super.put(field, op, jacksonDBCollection.serializeField(value)); }
@Override protected DBCursor<T> putGroup(String op, Object... expressions) { checkExecuted(); Object[] serialized = new Object[expressions.length]; for (int i = 0; i < expressions.length; i++) { serialized[i] = jacksonDBCollection.serializeField(expressions[i]); } return super.putGroup(op, serialized); } }
/** * Performs an update operation. * * @param id The id of the document to update * @param update update with which to update <tt>query</tt> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> updateById(K id, DBUpdate.Builder update) throws MongoException { return this.update(createIdQuery(id), update.serialiseAndGet(objectMapper)); }
/** * Performs an update operation. * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> update(DBObject query, DBUpdate.Builder update) throws MongoException { return this.update(query, update.serialiseAndGet(objectMapper)); }
/** * calls {@link DBCollection#update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean)} with upsert=false and multi=true * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> updateMulti(DBObject query, DBUpdate.Builder update) throws MongoException { return this.updateMulti(query, update.serialiseAndGet(objectMapper)); }
/** * Add the given values to the array value if they don't already exist in the specified field atomically * * @param field The field to add the values to * @param values The values to add * @return this object */ public static Builder addToSet(String field, List<?> values) { return new Builder().addToSet(field, values); }
/** * Perform a bit operation on the given field * * @param field The field to perform the operation on * @param operation The operation to perform * @param value The value * @return this object */ public static Builder bit(String field, String operation, int value) { return new Builder().bit(field, operation, value); }
/** * Find an object by the given id * * @param id The id * @return The object * @throws MongoException If an error occurred */ public T findOneById(K id, T fields) throws MongoException { return findOneById(id, convertToBasicDbObject(fields)); }
/** * The array field is of the given size * * @param field The field to compare * @param size The value to compare * @return the query */ public Q size(String field, int size) { return put(field, QueryOperators.SIZE, size); }
/** * creates a copy of this cursor object that can be iterated. * Note: * - you can iterate the DBCursor itself without calling this method * - no actual data is getting copied. * * @return The iterator */ public Iterator<T> iterator() { return this.copy(); }
/** * None of the given expressions matches * * @param expressions The expressions to test * @return the query */ public Q nor(Query... expressions) { return putGroup("$nor", expressions); }
/** * Find an object by the given id * * @param id The id * @return The object * @throws MongoException If an error occurred */ public T findOneById(K id) throws MongoException { return findOneById(id, (DBObject) null); }
/** * calls {@link DBCollection#getCount(com.mongodb.DBObject, com.mongodb.DBObject)} with null fields. * * @param query query to match * @return The count * @throws MongoException If an error occurred */ public long getCount(T query) throws MongoException { return getCount(query, null); }
@Override protected DBCursor<T> put(String field, String op, Object value) { checkExecuted(); return super.put(field, op, jacksonDBCollection.serializeField(value)); }
@Override protected DBCursor<T> putGroup(String op, Object... expressions) { checkExecuted(); Object[] serialized = new Object[expressions.length]; for (int i = 0; i < expressions.length; i++) { serialized[i] = jacksonDBCollection.serializeField(expressions[i]); } return super.putGroup(op, serialized); } }
/** * Performs an update operation. * * @param id The id of the document to update * @param update update with which to update <tt>query</tt> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> updateById(K id, DBUpdate.Builder update) throws MongoException { return this.update(createIdQuery(id), update.serialiseAndGet(objectMapper)); }
/** * Performs an update operation. * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> update(DBObject query, DBUpdate.Builder update) throws MongoException { return this.update(query, update.serialiseAndGet(objectMapper)); }
/** * calls {@link DBCollection#update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean)} with upsert=false and multi=true * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> updateMulti(DBObject query, DBUpdate.Builder update) throws MongoException { return this.updateMulti(query, update.serialiseAndGet(objectMapper)); }
/** * The given field matches the regular expression * * @param field The field to comare * @param regex The regular expression to match with * @return the query */ public Q regex(String field, Pattern regex) { return put(field, null, regex); }