<commit_before>import mongoose from 'mongoose';
import config from './config';
import { outputErr } from './log';

function connectMongo () {
  mongoose.connect(config.mongo.uri, config.mongo.options);
  mongoose.connection.on('error', err => {
    outputErr(`MongoDB connection error : ${err}`);
    process.exit(-1);
  });
}

function disconnectMongo () {
  mongoose.disconnect();
}

function findAndUpdateMongoDocument (doc, query, newData) {
  return new Promise((resolve, reject) => {
    doc.findOneAndUpdate(query, newData, { upsert: true }, (err, doc) => {
      if (err) {
        reject(err);
      } else {
        resolve(doc);
      }
    });<commit_msg>Fix mongoose warning<commit_after>import mongoose from 'mongoose';
import config from './config';
import { outputErr } from './log';

function connectMongo () {
  mongoose.Promise = global.Promise;
  mongoose.connect(config.mongo.uri, config.mongo.options);
  mongoose.connection.on('error', err => {
    outputErr(`MongoDB connection error : ${err}`);
    process.exit(-1);
  });
}

function disconnectMongo () {
  mongoose.disconnect();
}

function findAndUpdateMongoDocument (doc, query, newData) {
  return new Promise((resolve, reject) => {
    doc.findOneAndUpdate(query, newData, { upsert: true }, (err, doc) => {
      if (err) {
        reject(err);
      } else {
        resolve(doc);
      }
    });
{'fraction_non_alphanumeric': 0.1567489114658926, 'fraction_numerical': 0.001451378809869376, 'mean_word_length': 3.536184210526316, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7072011', 'n_tokens_mistral': 435, 'n_tokens_neox': 446, 'n_words': 96}