<commit_before>const Organization = require('../../domain/models/data/organization');
const { NotFoundError } = require('../../domain/errors');

module.exports = {

  saveFromModel(organizationModel) {
    return organizationModel.save();
  },

  isCodeAvailable(code) {
    return Organization
      .where({ code })
      .fetch()
      .then(organizations => {

        if(organizations) {
          return Promise.reject();
        }

        return Promise.resolve(code);
      });
  },

  isOrganizationIdExist(id) {
    return Organization
      .where({ id })
      .fetch()
      .then(organizations => {
        if(!organizations) {
          return Promise.reject(new NotFoundError('l’organisation n’existe pas'));
        }
        return Promise.resolve(true);
      });
  },

  get(id) {
    return Organization
      .where({ id: id })
      .fetch({ require: true });
  },

  findBy(filters) {
    return Organization.where(filters).fetchAll();
  },
<commit_msg>isOrganizationIdExist should return a promise with a boolean<commit_after>const Organization = require('../../domain/models/data/organization');

module.exports = {

  saveFromModel(organizationModel) {
    return organizationModel.save();
  },

  isCodeAvailable(code) {
    return Organization
      .where({ code })
      .fetch()
      .then(organizations => {

        if(organizations) {
          return Promise.reject();
        }

        return Promise.resolve(code);
      });
  },

  isOrganizationIdExist(id) {
    return Organization
      .where({ id })
      .fetch()
      .then(organizations => {
        if(!organizations) {
          return false;
        }
        return true;
      });
  },

  get(id) {
    return Organization
      .where({ id: id })
      .fetch({ require: true });
  },

  findBy(filters) {
    return Organization.where(filters).fetchAll();
  },

{'fraction_non_alphanumeric': 0.14392723381487427, 'fraction_numerical': 0.0, 'mean_word_length': 2.3156028368794326, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6986200', 'n_tokens_mistral': 541, 'n_tokens_neox': 522, 'n_words': 99}