/** * Performs an update operation. * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @param upsert if the database should create the element if it does not exist * @param multi if the update should be applied to all objects matching (db version 1.1.3 and above). An object will * not be inserted if it does not exist in the collection and upsert=true and multi=true. * See <a href="http://www.mongodb.org/display/DOCS/Atomic+Operations">http://www.mongodb.org/display/DOCS/Atomic+Operations</a> * @param concern the write concern * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> update(DBObject query, DBUpdate.Builder update, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return this.update(query, update.serialiseAndGet(objectMapper), upsert, multi, concern); }
/** * Performs an update operation. * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @param upsert if the database should create the element if it does not exist * @param multi if the update should be applied to all objects matching (db version 1.1.3 and above). An object will * not be inserted if it does not exist in the collection and upsert=true and multi=true. * See <a href="http://www.mongodb.org/display/DOCS/Atomic+Operations">http://www.mongodb.org/display/DOCS/Atomic+Operations</a> * @param concern the write concern * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> update(DBObject query, DBUpdate.Builder update, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return this.update(query, update.serialiseAndGet(objectMapper), upsert, multi, concern); }
/** * Finds the first document in the query and updates it. * * @param query query to match * @param fields fields to be returned * @param sort sort to apply before picking first document * @param remove if true, document found will be removed * @param update update to apply * @param returnNew if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever) * @param upsert do upsert (insert if document not present) * @return the object */ public T findAndModify(DBObject query, DBObject fields, DBObject sort, boolean remove, DBUpdate.Builder update, boolean returnNew, boolean upsert) { return convertFromDbObject(dbCollection.findAndModify(serializeFields(query), fields, sort, remove, update.serialiseAndGet(objectMapper), returnNew, upsert)); }
/** * Performs an update operation. * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @param upsert if the database should create the element if it does not exist * @param multi if the update should be applied to all objects matching (db version 1.1.3 and above). An object will * not be inserted if it does not exist in the collection and upsert=true and multi=true. * See <a href="http://www.mongodb.org/display/DOCS/Atomic+Operations">http://www.mongodb.org/display/DOCS/Atomic+Operations</a> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> update(DBObject query, DBUpdate.Builder update, boolean upsert, boolean multi) throws MongoException { return this.update(query, update.serialiseAndGet(objectMapper), upsert, multi); }
/** * Performs an update operation. * * @param query search query for old object to update * @param update update with which to update <tt>query</tt> * @param upsert if the database should create the element if it does not exist * @param multi if the update should be applied to all objects matching (db version 1.1.3 and above). An object will * not be inserted if it does not exist in the collection and upsert=true and multi=true. * See <a href="http://www.mongodb.org/display/DOCS/Atomic+Operations">http://www.mongodb.org/display/DOCS/Atomic+Operations</a> * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> update(DBObject query, DBUpdate.Builder update, boolean upsert, boolean multi) throws MongoException { return this.update(query, update.serialiseAndGet(objectMapper), upsert, multi); }
/** * 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)); }
/** * 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)); }
/** * 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)); }
/** * 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)); }