<commit_before>'use strict';

/**
 * Module dependencies
 */

// Local utils.
const actionUtil = require('../actionUtil');

/**
 * Find a specific entry
 */

module.exports = function findOne(_ctx) {
  const deferred = Promise.defer();

  // Return the model used.
  const Model = actionUtil.parseModel(_ctx);

  // Locate and validate the required `id` parameter.
  const pk = actionUtil.requirePk(_ctx);

  // Init the query.
  let query = Model.findOne(pk);
  query = actionUtil.populateEach(query, _ctx, Model);
  query.exec(function found(err, matchingRecord) {
    if (err) {
      _ctx.status = 500;
      deferred.reject(err);
    }
    if (!matchingRecord) {
      _ctx.status = 404;

      return deferred.reject({
        message: 'No ' + Model.name + ' found with the specified `id`.'
      });
    }
<commit_msg>Add select for findOne method<commit_after>'use strict';

/**
 * Module dependencies
 */

// Local utils.
const actionUtil = require('../actionUtil');

/**
 * Find a specific entry
 */

module.exports = function findOne(_ctx) {
  const deferred = Promise.defer();

  // Return the model used.
  const Model = actionUtil.parseModel(_ctx);

  // Locate and validate the required `id` parameter.
  const pk = actionUtil.requirePk(_ctx);

  // Build criteria object
  const criteria = {};
  criteria[Model.primaryKey] = pk;

  _.merge(criteria, actionUtil.parseSelect(_ctx));

  // Init the query.
  let query = Model.findOne(criteria);
  query = actionUtil.populateEach(query, _ctx, Model);
  query.exec(function found(err, matchingRecord) {
    if (err) {
      _ctx.status = 500;
      deferred.reject(err);
    }
    if (!matchingRecord) {
      _ctx.status = 404;

      return deferred.reject({
        message: 'No ' + Model.name + ' found with the specified `id`.'
      });
    }

{'fraction_non_alphanumeric': 0.13756906077348066, 'fraction_numerical': 0.0066298342541436465, 'mean_word_length': 2.928416485900217, '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': '5391210', 'n_tokens_mistral': 580, 'n_tokens_neox': 554, 'n_words': 149}