Search in sources :

Example 6 with Find

use of org.jongo.Find in project profile by craftercms.

the class ProfileRepositoryImpl method findRange.

@Override
public Iterable<Profile> findRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws MongoDataException {
    try {
        String query = getQueryFor(KEY_FIND_BY_TENANT_QUERY);
        Find find = getCollection().find(query, tenantName);
        addSort(find, sortBy, sortOrder);
        addRange(find, start, count);
        addProjection(find, attributesToReturn);
        return find.as(Profile.class);
    } catch (MongoException ex) {
        String msg = "Unable to find range of profiles for tenant '" + tenantName + "'";
        logger.error(msg, ex);
        throw new MongoDataException(msg, ex);
    }
}
Also used : MongoException(com.mongodb.MongoException) Find(org.jongo.Find) MongoDataException(org.craftercms.commons.mongo.MongoDataException)

Aggregations

MongoException (com.mongodb.MongoException)6 MongoDataException (org.craftercms.commons.mongo.MongoDataException)6 Find (org.jongo.Find)6 ArrayList (java.util.ArrayList)1 ObjectId (org.bson.types.ObjectId)1