<commit_before>const mongoose = require('mongoose');

module.exports = {
    getDb() {
        const dbDev = 'mongodb://localhost:27017/drones';
        mongoose.connect(dbDev);
        const db = mongoose.connection;

        // const dbProd = 'mongodb://<dbname>:<dbpass>@<EMAIL>:11748/drone-fleet'



        // test to see if DB is working
        // const droneSchema = mongoose.Schema({
        //     model: String
        // });
        // const modelName = 'FlyingWarior';

        // const Drone = mongoose.model(modelName, droneSchema);

        // const someDrone = new Drone({
        //     model: 'B52'
        // });
        // someDrone.save((err, entry, numAffected) => {
        //     console.log(entry);
        //     console.log(numAffected);
        // });

        return db;
    }
};<commit_msg>added events indicating db start/error<commit_after>const mongoose = require('mongoose');

module.exports = {
    getDb() {
        const dbDev = 'mongodb://localhost:27017/drones';
        // const dbProd = 'mongodb://<dbname>:<dbpass>@ds<EMAIL>.mlab.com:11748/drone-fleet'

        mongoose.connect(dbDev);
        const db = mongoose.connection;

        db.on('error', (err) => {
            console.log('Connection failed!\n' + err);
        });

        db.on('open', () => {
            console.log('Db connection successfully established!');
        });





        // test to see if DB is working
        // const droneSchema = mongoose.Schema({
        //     model: String
        // });
        // const modelName = 'FlyingWarior';

        // const Drone = mongoose.model(modelName, droneSchema);

        // const someDrone = new Drone({
        //     model: 'B52'
        // });
        // someDrone.save((err, entry, numAffected) => {
        //     console.log(entry);
        //     console.log(numAffected);
        // });

        return db;
    }
};
{'fraction_non_alphanumeric': 0.15795034337031166, 'fraction_numerical': 0.012678288431061807, 'mean_word_length': 1.764963503649635, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '1574722', 'n_tokens_mistral': 609, 'n_tokens_neox': 575, 'n_words': 108}