<commit_before>'use strict';

const _ = require('lodash');

module.exports = function (Model, bootOptions = {}) {
  Model.defineProperty('deleted', {
    type: Boolean,
    required: true,
    default: false
  });

  /**
   * @return {Promise<Model>}
   */
  Model.prototype.softDelete = function () {
    return this.updateAttribute('deleted', true);
  }

  /**
   * @return {Promise<Model>}
   */
  Model.prototype.restore = function () {
    return this.updateAttribute('deleted', false);
  }

  Model.beforeRemote('find', (ctx, instance, next) => {
    const scope = _.get(ctx.args, 'filter.scope', 'active');
    _.unset(ctx.args, 'filter.scope');
    switch (scope) {
      case 'active':
        _.set(ctx.args, 'filter.where.deleted', false);
        break;
      case 'inactive':
        _.set(ctx.args, 'filter.where.deleted', true);
        break;
      default:
        _.unset(ctx.args, 'filter.where.deleted');
        break;
    }
    process.nextTick(next);
  });
}
<commit_msg>Use not equal filter instead.<commit_after>'use strict';

const _ = require('lodash');

module.exports = function (Model, bootOptions = {}) {
  Model.defineProperty('deleted', {
    type: Boolean,
    required: true,
    default: false
  });

  /**
   * @return {Promise<Model>}
   */
  Model.prototype.softDelete = function () {
    return this.updateAttribute('deleted', true);
  }

  /**
   * @return {Promise<Model>}
   */
  Model.prototype.restore = function () {
    return this.updateAttribute('deleted', false);
  }

  Model.beforeRemote('find', (ctx, instance, next) => {
    const scope = _.get(ctx.args, 'filter.scope', 'active');
    _.unset(ctx.args, 'filter.scope');
    switch (scope) {
      case 'active':
        _.set(ctx.args, 'filter.where.deleted.neq', true);
        break;
      case 'inactive':
        _.set(ctx.args, 'filter.where.deleted', true);
        break;
      default:
        _.unset(ctx.args, 'filter.where.deleted');
        break;
    }
    process.nextTick(next);
  });
}

{'fraction_non_alphanumeric': 0.17339312406576982, 'fraction_numerical': 0.0, 'mean_word_length': 2.7673545966228894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2727869', 'n_tokens_mistral': 641, 'n_tokens_neox': 646, 'n_words': 122}