<commit_before>const queryBuilder = require('./QueryBuilder')
let parameters = require('./Parameters')
let _table = ''

/**
 * [Add More Conditions to the SQL Query]
 * @param {Object} conditions [description]
 * @param {String} andOr      [If before has another where clause then is possible to choose AND or OR]
 */
function addMoreConditions (conditions, andOr) {
  andOr = andOr.toLowerCase()
  if (andOr !== 'and' && andOr !== 'or') {
    throw new Error('The andOr variable is required to be AND or OR!')
  }

  let method = `${andOr}Where`
  for (let key in conditions) {
    if (conditions.hasOwnProperty(key)) {
      if (Array.isArray(conditions[key])) {
        queryBuilder.whereIn(key, conditions[key], andOr)
      } else {
        queryBuilder[method](key, '=', conditions[key])
      }
    }
  }
}

/**
 * [setModel description]
 * @param {String} [table=''] [Database table for that schema]
 */
module.exports.setTable = function (table = '') {
  if (_table === '') {
    if (typeof table === 'string' && table !== '') {
      _table = table
      return this
    } else {
      throw new Error('The table is not set!')
    }
  } else {
    if (typeof table === 'string' && table !== '') {
      _table = table
    }
    return this
  }
}

/**<commit_msg>Make the find by filed to work with array of values<commit_after>const queryBuilder = require('./QueryBuilder')
let parameters = require('./Parameters')
let _table = ''

/**
 * [Add More Conditions to the SQL Query]
 * @param {Object} conditions [description]
 * @param {String} andOr      [If before has another where clause then is possible to choose AND or OR]
 */
function addMoreConditions (conditions, andOr) {
  let method = checkWhereMethod(andOr)

  for (let key in conditions) {
    if (conditions.hasOwnProperty(key)) {
      if (Array.isArray(conditions[key])) {
        queryBuilder.whereIn(key, conditions[key], andOr)
      } else {
        queryBuilder[method](key, '=', conditions[key])
      }
    }
  }
}

function checkWhereMethod (andOr) {
  andOr = andOr.toLowerCase()
  if (andOr !== 'and' && andOr !== 'or') {
    throw new Error('The andOr variable is required to be AND or OR!')
  }

  return `${andOr}Where`
}

/**
 * [setModel description]
 * @param {String} [table=''] [Database table for that schema]
 */
module.exports.setTable = function (table = '') {
  if (_table === '') {
    if (typeof table === 'string' && table !== '') {
      _table = table
      return this
    } else {
      throw new Error('The table is not set!')
    }
  } else {
    if (typeof table === 'string' && table !== '') {
      _table = table
    }
    return this
  }
}

/**
{'fraction_non_alphanumeric': 0.15291902071563088, 'fraction_numerical': 0.0, 'mean_word_length': 3.012084592145015, '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': '184818', 'n_tokens_mistral': 801, 'n_tokens_neox': 805, 'n_words': 253}