code: public Object getDBCursorInstance(BasicDBObject mongoQuery, BasicDBObject orderBy, int maxResult, int firstResult,
              BasicDBObject keys, String documentName, boolean isCountQuery)
      {
          DBCollection dbCollection = mongoDb.getCollection(documentName);
          DBCursor cursor = null;
          if (isCountQuery)
              return dbCollection.count(mongoQuery);
          else
              cursor = orderBy != null ? dbCollection.find(mongoQuery, keys).sort(orderBy).limit(maxResult)
                      .skip(firstResult) : dbCollection.find(mongoQuery, keys).limit(maxResult).skip(firstResult);
          return cursor;
      }
docs: Gets the DB cursor instance.
  
  @param mongoQuery
  the mongo query
  @param orderBy
  the order by
  @param maxResult
  the max result
  @param firstResult
  the first result
  @param keys
  the keys
  @param documentName
  the document name
  @param isCountQuery
  the is count query
  @return the DB cursor instance