private DBCursor cursor(final DBObject filter, final String[] fieldNames,
final int skip, final int limit,
final String[] sortAscBy, final String[] sortDescBy) {
if (null != _coll) {
DBCursor cursor;
final DBObject fields = this.getFields(fieldNames, true);
final DBObject sort = BeeMongoUtils.getSortFields(sortAscBy, sortDescBy);
if (null != filter) {
cursor = null != fields
? _coll.find(filter, fields)
: _coll.find(filter);
} else {
cursor = null != fields
? _coll.find(new BasicDBObject(), fields)
: _coll.find();
}
// limit data
if (skip > 0 || limit > 0) {
if (skip > 0) {
cursor = cursor.skip(skip);
}
if (limit > 0) {
cursor = cursor.limit(limit);
}
}
// sort
if (null != cursor && null != sort) {
cursor = cursor.sort(sort);
}
return cursor;
}
return null;