/** * Returns the number of documents in the collection * that match the specified query * * @param query query to select documents to count * @param fields fields to return * @param limit limit the count to this value * @param skip number of entries to skip * @return number of documents that match query and fields * @throws MongoException If an error occurred */ public long getCount(T query, T fields, long limit, long skip) throws MongoException { return dbCollection.getCount(convertToBasicDbObject(query), convertToBasicDbObject(fields), limit, skip); }
/** * Returns the number of documents in the collection * that match the specified query * * @param query query to select documents to count * @param fields fields to return * @param limit limit the count to this value * @param skip number of entries to skip * @return number of documents that match query and fields * @throws MongoException If an error occurred */ public long getCount(T query, T fields, long limit, long skip) throws MongoException { return dbCollection.getCount(convertToBasicDbObject(query), convertToBasicDbObject(fields), limit, skip); }
/** * 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(T query, T object, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return update(convertToBasicDbObject(query), convertToBasicDbObject(object), 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(T query, T object, boolean upsert, boolean multi, WriteConcern concern) throws MongoException { return update(convertToBasicDbObject(query), convertToBasicDbObject(object), upsert, multi, concern); }
/** * 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)); }
/** * 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)); }
/** * Queries for an object in this collection. * <p/> * <p> * An empty DBObject will match every document in the collection. * Regardless of fields specified, the _id fields are always returned. * </p> * To keys object should have non null values for every key that you want to return * * @param query object for which to search * @param keys fields to return * @return a cursor to iterate over results */ public final DBCursor<T> find(T query, T keys) { return new DBCursor<T>(this, dbCollection.find(convertToBasicDbObject(query), convertToBasicDbObject(keys))); }
/** * Queries for an object in this collection. * <p/> * <p> * An empty DBObject will match every document in the collection. * Regardless of fields specified, the _id fields are always returned. * </p> * To keys object should have non null values for every key that you want to return * * @param query object for which to search * @param keys fields to return * @return a cursor to iterate over results */ public final DBCursor<T> find(T query, T keys) { return new DBCursor<T>(this, dbCollection.find(convertToBasicDbObject(query), convertToBasicDbObject(keys))); }
/** * Queries for an object in this collection. * * @param query object for which to search * @return an iterator over the results * @throws MongoException If an error occurred */ public DBCursor<T> find(T query) throws MongoException { return new DBCursor<T>(this, dbCollection.find(convertToBasicDbObject(query))); }
/** * Queries for an object in this collection. * * @param query object for which to search * @return an iterator over the results * @throws MongoException If an error occurred */ public DBCursor<T> find(T query) throws MongoException { return new DBCursor<T>(this, dbCollection.find(convertToBasicDbObject(query))); }