/** * 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, DBObject fields) throws MongoException { return findOne(createIdQuery(id), fields); }
/** * 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, DBObject fields) throws MongoException { return findOne(createIdQuery(id), fields); }
/** * 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); }
/** * 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=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 id the id of the document to remove * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> removeById(K id) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(createIdQuery(id))); }
/** * calls {@link DBCollection#remove(com.mongodb.DBObject, com.mongodb.WriteConcern)} with the default WriteConcern * * @param id the id of the document to remove * @return The write result * @throws MongoException If an error occurred */ public WriteResult<T, K> removeById(K id) throws MongoException { return new WriteResult<T, K>(this, dbCollection.remove(createIdQuery(id))); }
/** * 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)); }