/** * calls {@link DBCollection#remove(com.mongodb.DBObject, com.mongodb.WriteConcern)} with the default WriteConcern * * @param query * the query that documents to be removed must match * @return The write result * @throws MongoException * If an error occurred */ public WriteResult<T, K> remove(DBObject query) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(serializeFields(query))); }
/** * calls {@link DBCollection#remove(com.mongodb.DBObject, com.mongodb.WriteConcern)} with the default WriteConcern * * @param query * the query * @return The write result * @throws MongoException * If an error occurred */ public WriteResult<T, K> remove(DBQuery.Query query) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(serializeQuery(query))); }
/** * Removes objects from the database collection. * * @param query * the object that documents to be removed must match * @param concern * WriteConcern for this operation * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> remove(DBObject query, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove( serializeFields(query), concern)); }
/** * Inserts an object into the database. if the objects _id is null, one will * be generated you can get the _id that was generated by calling * getSavedObject() or getSavedId() on the result * * @param object * The object to insert * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> insert(T object) throws MongoException { DBObject dbObject = convertToDbObject(object); return new WriteResult<T, K>(this, dbCollection.insert(dbObject), dbObject); }
/** * Inserts objects into the database. if the objects _id is null, one will * be generated you can get the _id that were generated by calling * getSavedObjects() or getSavedIds() on the result * * @param objects * The objects to insert * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> insert(T... objects) throws MongoException { DBObject[] dbObjects = convertToDbObjects(objects); return new WriteResult<T, K>(this, dbCollection.insert(dbObjects), dbObjects); }
/** * Removes objects from the database collection. * * @param query * the query * @param concern * WriteConcern for this operation * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> remove(DBQuery.Query query, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove( serializeQuery(query), concern)); }
/** * Saves an object to this collection (does insert or update based on the * object _id). * * @param object * the <code>DBObject</code> to save * @param concern * the write concern * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> save(T object, WriteConcern concern) throws MongoException { DBObject dbObject = convertToDbObject(object); return new WriteResult<T, K>(this, dbCollection.save(dbObject, concern), dbObject); }
/** * Inserts an object into the database. if the objects _id is null, one will * be generated you can get the _id that was generated by calling * getSavedObject() or getSavedId() on the result * * @param object * The object to insert * @param concern * the write concern * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> insert(T object, WriteConcern concern) throws MongoException { DBObject dbObject = convertToDbObject(object); return new WriteResult<T, K>(this, dbCollection.insert(dbObject, concern), dbObject); }
/** * Inserts objects into the database. if the objects _id is null, one will * be generated you can get the _id that were generated by calling * getSavedObjects() or getSavedIds() on the result * * @param objects * The objects to insert * @param concern * the write concern * @return The result * @throws MongoException * If an error occurred */ public WriteResult<T, K> insert(WriteConcern concern, T... objects) throws MongoException { DBObject[] dbObjects = convertToDbObjects(objects); return new WriteResult<T, K>(this, dbCollection.insert(concern, dbObjects), dbObjects); }
/** * Performs an update operation. * * @param query * search query for old object to update * @param object * object 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, DBObject object, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.update( serializeFields(query), object, 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(DBQuery.Query query, DBUpdate.Builder update, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.update( serializeQuery(query), update.serialiseAndGet(objectMapper, type), upsert, multi, concern)); }
/** * Performs an update operation. * * @param query * search query for old object to update * @param object * object 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(DBQuery.Query query, T object, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.update( serializeQuery(query), convertToBasicDbObject(object), upsert, multi, concern)); }