<commit_before>'use strict';

/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
  errorHandler = require('./errors.server.controller'),
  Category = mongoose.model('Category'),
   _ = require('lodash');

/**
 * Create a Category
 */
exports.create = function(req, res) {

  var category = new Category(req.body);

  category.save(function(err) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      res.status(201).json(category);
    }
  });

};

/**
 * Show the current Category
 */
exports.read = function(req, res) {

  Category.findById(req.params.categoryId).exec(function(err, category) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      if (!category) {
        return res.status(404).send({
          message: 'Category not found'
        });
      }
      res.json(category);
    }
  });

};

/**
 * Update a Category
 */
exports.update = function(req, res) {

  var category = req.category;

  category = _.extend(category, req.body);

  category.save(function(err) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      res.json(category);
    }
  });
  
};

/**
 * Delete an Category
 */
exports.delete = function(req, res) {

};

/**
 * List of Categories
 */
exports.list = function(req, res) {

  Category.find().exec(function (err, categories) {
    if (err){
      return res.status(400).send({
          message: errorHandler.getErrorMessage(err)
        });
    } else {
      res.json(categories);
    }
  });

};
<commit_msg>Modify Category controller for delete function.<commit_after>'use strict';

/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
  errorHandler = require('./errors.server.controller'),
  Category = mongoose.model('Category'),
   _ = require('lodash');

/**
 * Create a Category
 */
exports.create = function(req, res) {

  var category = new Category(req.body);

  category.save(function(err) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      res.status(201).json(category);
    }
  });

};

/**
 * Show the current Category
 */
exports.read = function(req, res) {

  Category.findById(req.params.categoryId).exec(function(err, category) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      if (!category) {
        return res.status(404).send({
          message: 'Category not found'
        });
      }
      res.json(category);
    }
  });

};

/**
 * Update a Category
 */
exports.update = function(req, res) {

  var category = req.category;

  category = _.extend(category, req.body);

  category.save(function(err) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      res.json(category);
    }
  });

};

/**
 * Delete an Category
 */
exports.delete = function(req, res) {

  var category = req.category;

  category.remove(function(err) {
    if (err) {
      return res.status(400).send({
        message: errorHandler.getErrorMessage(err)
      });
    } else {
      res.json(category);
    }
  });
  
};

/**
 * List of Categories
 */
exports.list = function(req, res) {

  Category.find().exec(function (err, categories) {
    if (err){
      return res.status(400).send({
          message: errorHandler.getErrorMessage(err)
        });
    } else {
      res.json(categories);
    }
  });

};

{'fraction_non_alphanumeric': 0.16267029972752042, 'fraction_numerical': 0.010626702997275205, 'mean_word_length': 2.5332050048123196, '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': '3130240', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1155, 'n_words': 217}