<commit_before>/**
 * @param {Object}  params
 * @param {Model}     params.model
 * @param {Object}    [params.conditions]
 * @param {Object}    [params.populate]
 * @param {Object}    [params.sort]
 * @param {Number}    [params.limit]
 * @param {Number}    [params.offset]
 * @param {Boolean}   [params.lean=true]
 *
 * @returns {Promise}
 */
module.exports = function(params) {
    var model      = params.model;
    var conditions = params.conditions || {};
    var populate   = params.populate;
    var sort       = params.sort || {};
    var limit      = params.hasOwnProperty('limit') ? params.limit : 20;
    var offset     = params.hasOwnProperty('offset') ? params.offset : 0;
    var lean       = params.hasOwnProperty('lean') ? params.lean : true;

    var collectionPromise = Promise.resolve([]);
    if (limit) {
        var query = model.find(conditions)
                         .sort(sort)
                         .limit(limit)
                         .skip(offset)
                         .lean(lean);

        if (populate) {
            query = query.populate(populate);
        }

        collectionPromise = query.exec();
    }

    var totalCountPromise = model.count(conditions).exec();

    return Promise.all([collectionPromise, totalCountPromise]).then(function(result) {
        var data       = result[0];
        var totalCount = result[1];

        if (lean) {
            data.forEach(function(item) {
                item.id = item._id;
            });
        }

        var meta = {
            limit:      limit,
            offset:     offset,
            totalCount: totalCount
        };

        return {
            data: data,
            meta: meta
        };
    });<commit_msg>select option<commit_after>/**
 * @param {Object}        params
 * @param {Model}           params.model
 * @param {Object}          [params.conditions={}]
 * @param {Object|String}   [params.select]
 * @param {Object|String}   [params.populate]
 * @param {Object|String}   [params.sort={}]
 * @param {Number}          [params.limit=20]
 * @param {Number}          [params.offset=0]
 * @param {Boolean}         [params.lean=true]
 *
 * @returns {Promise}
 */
module.exports = function(params) {
    var model      = params.model;
    var conditions = params.conditions || {};
    var select     = params.select;
    var populate   = params.populate;
    var sort       = params.sort || {};
    var limit      = params.hasOwnProperty('limit') ? params.limit : 20;
    var offset     = params.hasOwnProperty('offset') ? params.offset : 0;
    var lean       = params.hasOwnProperty('lean') ? params.lean : true;

    var collectionPromise = Promise.resolve([]);
    if (limit) {
        var query = model.find(conditions)
                         .sort(sort)
                         .limit(limit)
                         .skip(offset)
                         .lean(lean);

        if (select) {
            query.select(select);
        }

        if (populate) {
            query.populate(populate);
        }

        collectionPromise = query.exec();
    }

    var totalCountPromise = model.count(conditions).exec();

    return Promise.all([collectionPromise, totalCountPromise]).then(function(result) {
        var data       = result[0];
        var totalCount = result[1];

        if (lean) {
            data.forEach(function(item) {
                item.id = item._id;
            });
        }

        var meta = {
            limit:      limit,
            offset:     offset,
            totalCount: totalCount
        };

        return {
            data: data,
            meta: meta
        };
    });
{'fraction_non_alphanumeric': 0.13000548546352167, 'fraction_numerical': 0.0035655512890839275, 'mean_word_length': 1.6816176470588236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3254924', 'n_tokens_mistral': 1021, 'n_tokens_neox': 1002, 'n_words': 217}