<commit_before>/*
 * RestController *
 * the rest controller class provides basic rest methods to a controller *
 */

//require dependencies
var Controller = require('./controller');

module.exports = Controller.extend({

  _init: function(app) {

    //call base class constructor
    this._super(app);

    //mark controller as rest enabled
    this.restEnabled = true;

  },

  search: function(req, callback) {

    //maintain reference to self
    var self = this;

    //validate parameters
    var params = req.body || {};

    //search database
    this.model.find()
      .where(params)
      .then(function(results) {
        callback({success: true, message: "Successfully searched the " + self.name + " database...", results: results});
      }).fail( function(err) {
        callback({success: false, message: "Failed to search the " + self.name + " database...", error: err});
      });
  },

  create: function(req, callback) {

    //maintain reference to self
    var self = this;<commit_msg>Added support for passing in where, sort, limit, and skip parameters via query string or post on search.<commit_after>/*
 * RestController *
 * the rest controller class provides basic rest methods to a controller *
 */

//require dependencies
var Controller = require('./controller');

module.exports = Controller.extend({

  _init: function(app) {

    //call base class constructor
    this._super(app);

    //mark controller as rest enabled
    this.restEnabled = true;

  },

  search: function(req, callback) {

    //maintain reference to self
    var self = this;

    //validate parameters
    var where = req.param('where');
    var sort = req.param('sort');
    var limit = req.param('limit');
    var skip = req.param('skip') || 0;

    //search database
    this.model.find()
      .where(where)
      .limit(limit)
      .skip(skip)
      .sort(sort)
      .then(function(results) {
        callback({success: true, message: "Successfully searched the " + self.name + " database...", results: results});
      }).fail( function(err) {
        callback({success: false, message: "Failed to search the " + self.name + " database...", error: err});
      });
  },

  create: function(req, callback) {

    //maintain reference to self
    var self = this;
{'fraction_non_alphanumeric': 0.13532513181019332, 'fraction_numerical': 0.0004393673110720562, 'mean_word_length': 2.8076923076923075, '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': '3980911', 'n_tokens_mistral': 642, 'n_tokens_neox': 615, 'n_words': 203}