<commit_before>'use strict';

var _ = require('lodash')
  , Promise = require('bluebird')
  , RelationExpression = require('./RelationExpression')
  , ValidationError = require('./ValidationError')
  , utils = require('./utils')
  , jsonFieldExpressionParser = require('./jsonFieldExpressionParser');

/**
 * Query builder for Models.
 *
 * This class is a wrapper around <a href="http://knexjs.org#Builder">knex QueryBuilder</a>.
 * QueryBuilder has all the methods a knex QueryBuilder has and more. While knex
 * QueryBuilder returns plain javascript objects, QueryBuilder returns Model
 * subclass instances.
 *
 * QueryBuilder is thenable, meaning that it can be used like a promise. You can
 * return query builder from a `.then` method of a promise and it gets chained just like
 * a normal promise would.
 *
 * The query is executed when one of its promise methods `then()`, `catch()`, `map()`,
 * `bind()` or `return()` is called.
 *
 * @constructor
 */
function QueryBuilder(modelClass) {
  this._modelClass = modelClass;
  this._knexCalls = [];

  this._explicitResolveValue = null;
  this._explicitRejectValue = null;

  this._runBefore = [];
  this._runAfterKnexQuery = [];
  this._runAfterModelCreate = [];
  this._runAfter = [];

  this._findImpl = null;
  this._insertImpl = null;
  this._updateImpl = null;
  this._patchImpl = null;
  this._deleteImpl = null;
  this._relateImpl = null;
  this._unrelateImpl = null;

  this._eagerExpression = null;
  this._allowedEagerExpression = null;
}
<commit_msg>add extend method for QueryBuilder<commit_after>'use strict';

var _ = require('lodash')
  , Promise = require('bluebird')
  , RelationExpression = require('./RelationExpression')
  , ValidationError = require('./ValidationError')
  , utils = require('./utils')
  , jsonFieldExpressionParser = require('./jsonFieldExpressionParser');

/**
 * Query builder for Models.
 *
 * This class is a wrapper around <a href="http://knexjs.org#Builder">knex QueryBuilder</a>.
 * QueryBuilder has all the methods a knex QueryBuilder has and more. While knex
 * QueryBuilder returns plain javascript objects, QueryBuilder returns Model
 * subclass instances.
 *
 * QueryBuilder is thenable, meaning that it can be used like a promise. You can
 * return query builder from a `.then` method of a promise and it gets chained just like
 * a normal promise would.
 *
 * The query is executed when one of its promise methods `then()`, `catch()`, `map()`,
 * `bind()` or `return()` is called.
 *
 * @constructor
 */
function QueryBuilder(modelClass) {
  this._modelClass = modelClass;
  this._knexCalls = [];

  this._explicitResolveValue = null;
  this._explicitRejectValue = null;

  this._runBefore = [];
  this._runAfterKnexQuery = [];
  this._runAfterModelCreate = [];
  this._runAfter = [];

  this._findImpl = null;
  this._insertImpl = null;
  this._updateImpl = null;
  this._patchImpl = null;
  this._deleteImpl = null;
  this._relateImpl = null;
  this._unrelateImpl = null;

  this._eagerExpression = null;
  this._allowedEagerExpression = null;
}

/**
 * Makes the given constructor a subclass of this class.
 *
 * @param {function=} subclassConstructor
 * @return {function}
 */
QueryBuilder.extend = function (subclassConstructor) {
  utils.inherits(subclassConstructor, this);
  return subclassConstructor;
};

{'fraction_non_alphanumeric': 0.11977129100210653, 'fraction_numerical': 0.0, 'mean_word_length': 4.242902208201893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4781092', 'n_tokens_mistral': 972, 'n_tokens_neox': 947, 'n_words': 293}