<commit_before>var personObjects = require('../models/person');
var MongoClient = require('mongodb').MongoClient;
var config = require('../../config');
var url = config.mongoCn;

var db = null;

MongoClient.connect(url, function(err, database) {
    if(err) {
        console.log('Could not connect to mongo db instance at url: ' + url +
        '. Shutting down.');
        process.exit();
    }
    db = database;
});

exports.createPerson = function(person, cb) {
    db.collection('persons').insertOne(person, function(err, result) {
        if(err) return cb({err: true, message: err});
        cb({err: false, result: result});
    });
};

exports.findByEmail = function(email, cb) {
    var cursor = db.collection('persons').find( {'email': email});
    cursor.each(function(err, res) {
        console.log(res);
    });
};<commit_msg>Finished findbyemail<commit_after>var personObjects = require('../models/person');
var MongoClient = require('mongodb').MongoClient;
var config = require('../../config');
var url = config.mongoCn;

var db = null;

MongoClient.connect(url, function(err, database) {
    if(err) {
        console.log('Could not connect to mongo db instance at url: ' + url +
        '. Shutting down.');
        process.exit();
    }
    db = database;
});

exports.createPerson = function(person, cb) {
    db.collection('persons').insertOne(person, function(err, result) {
        if(err) return cb({err: true, message: err});
        cb({err: false, result: result});
    });
};

exports.findByEmail = function(email, cb) {
    db.collection('persons').findOne( {'email': email}, function(err, res) {
        if(err) return cb({err: true, message: err});
        if(!res) return cb({err: true, message: 'Could not find person with email \'' + email + '\'.'});
        else cb(res);
    });
};

exports.updatePerson = function(person, cb) {
    exports.findByEmail(person.eamil, function(res) {
        if(res.err) cb(res);
    });
};
{'fraction_non_alphanumeric': 0.1760204081632653, 'fraction_numerical': 0.0, 'mean_word_length': 3.300438596491228, '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': '119606', 'n_tokens_mistral': 615, 'n_tokens_neox': 610, 'n_words': 147}