DBObject[] convertToDbObjects(T... objects) throws MongoException { DBObject[] results = new DBObject[objects.length]; for (int i = 0; i < objects.length; i++) { results[i] = convertToDbObject(objects[i]); } return results; }
DBObject[] convertToDbObjects(T... objects) throws MongoException { DBObject[] results = new DBObject[objects.length]; for (int i = 0; i < objects.length; i++) { results[i] = convertToDbObject(objects[i]); } return results; }
/** * 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); }
/** * Removes objects from the database collection. * * @param object 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(T object, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(convertToDbObject(object), concern)); }
/** * Removes objects from the database collection. * * @param object 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(T object, WriteConcern concern) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(convertToDbObject(object), concern)); }
/** * calls {@link DBCollection#remove(com.mongodb.DBObject, com.mongodb.WriteConcern)} with the default WriteConcern * * @param object the object that documents to be removed must match * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> remove(T object) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(convertToDbObject(object))); }
/** * 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); }
/** * calls {@link DBCollection#update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean)} with upsert=false and multi=false * * @param id the id of the object to update * @param object object with which to update <tt>query</tt> * @return The result * @throws MongoException If an error occurred */ public WriteResult<T, K> updateById(K id, T object) throws MongoException { return update(createIdQuery(id), convertToDbObject(object), false, false); }
/** * calls {@link DBCollection#remove(com.mongodb.DBObject, com.mongodb.WriteConcern)} with the default WriteConcern * * @param object the object that documents to be removed must match * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> remove(T object) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(convertToDbObject(object))); }
/** * calls {@link DBCollection#update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean)} with upsert=false and multi=false * * @param id the id of the object to update * @param object object with which to update <tt>query</tt> * @return The result * @throws MongoException If an error occurred */ public WriteResult<T, K> updateById(K id, T object) throws MongoException { return update(createIdQuery(id), convertToDbObject(object), false, false); }
/** * 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 * @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 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 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); }