<commit_before>'use strict';

module.exports = function() {

  const db = require('../server/db.js');
  const sequelize = db.connection;

  function _create(data, err, success) {
    let payload = {
      userId: data.userId,
      name: data.name
    };
    db.intolerances.create(payload)
    .then(success)
    .catch(err)
  }

  function _find(data, err, success) {
    let payload = data;
    db.intolerances.findAll({
      where: {
        userId: payload.userId
      }
    })
    .then(success)
    .catch(err)
  }

  function _findAll(err, success) {
    db.intolerances.findAll()
    .then(success)
    .catch(err)
  }

  function _update(data, err, success) {
    let payload = data;
    db.intolerances.find({
      where: {
        intoleranceId: payload.intoleranceId,
        userId: payload.userId
      }
    })
    .then((matchedIntolerance) => {
      matchedIntolerance.updateAttributes(payload)
      .then(success)
      .catch(err)
    })
    .catch(err)
  }

  function _destroy(data, err, success) {
    let payload = data;
    db.intolerances.destroy({
      where: {
        intoleranceId: payload.intoleranceId
        userId: payload.userId
      }
    })
    .then(success)
    .catch(err)
  }

  function _findOrCreate(data, err, success) {
    let payload = data;
    db.users.findOrCreate({
      where: {
        userId: payload.userId,
        intoleranceId: payload.intoleranceId
      },
      defaults: {
        userId: payload.userId,
        name: payload.name
      }
    })<commit_msg>fixed the issue i believe<commit_after>'use strict';

module.exports = function() {

  const db = require('../server/db.js');
  const sequelize = db.connection;

  function _create(data, err, success) {
    let payload = {
      userId: data.userId,
      name: data.name
    };
    db.intolerances.create(payload)
    .then(success)
    .catch(err)
  }

  function _find(data, err, success) {
    let payload = data;
    db.intolerances.findAll({
      where: {
        userId: payload.userId
      }
    })
    .then(success)
    .catch(err)
  }

  function _findAll(err, success) {
    db.intolerances.findAll()
    .then(success)
    .catch(err)
  }

  function _update(data, err, success) {
    let payload = data;
    db.intolerances.find({
      where: {
        intoleranceId: payload.intoleranceId,
        userId: payload.userId
      }
    })
    .then((matchedIntolerance) => {
      matchedIntolerance.updateAttributes(payload)
      .then(success)
      .catch(err)
    })
    .catch(err)
  }

  function _destroy(data, err, success) {
    let payload = data;
    db.intolerances.destroy({
      where: {
        intoleranceId: payload.intoleranceId
        userId: payload.userId
      }
    })
    .then(success)
    .catch(err)
  }

  function _findOrCreate(data, err, success) {
    let payload = data;
    db.intolerances.findOrCreate({
      where: {
        userId: payload.userId,
        intoleranceId: payload.intoleranceId
      },
      defaults: {
        userId: payload.userId,
        name: payload.name
      }
    })
{'fraction_non_alphanumeric': 0.12349691257718556, 'fraction_numerical': 0.0, 'mean_word_length': 2.202913631633715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3477401', 'n_tokens_mistral': 1011, 'n_tokens_neox': 1002, 'n_words': 190}