<commit_before>'use strict';

//contrib
const mongoose = require('mongoose');
const winston = require('winston');

//mine
const config = require('../../config');
const logger = new winston.Logger(config.logger.winston);
const events = require('../events');

mongoose.Promise = global.Promise; //use native promise for mongoose

exports.init = function(cb) {
    mongoose.connect(config.mongodb, {}, function(err) {
        if(err) return cb(err);
        logger.info("connected to mongo");
        cb();
    });
}
exports.disconnect = function(cb) {
    mongoose.disconnect(cb);
}

///////////////////////////////////////////////////////////////////////////////////////////////////

//workflow instance
var instanceSchema = mongoose.Schema({

    workflow_id: String, //"sca-wf-life"

    name: String, //name of the workflow
    desc: String, //desc of the workflow

    //user that this workflow instance belongs to
    user_id: {type: String, index: true}, 

    config: mongoose.Schema.Types.Mixed,

    create_date: {type: Date, default: Date.now },
    update_date: {type: Date, default: Date.now },
});
/*<commit_msg>promise override for mongoose seems like it's nolonger necessary (Default to es6 promise?)<commit_after>'use strict';

//contrib
const mongoose = require('mongoose');
const winston = require('winston');

//mine
const config = require('../../config');
const logger = new winston.Logger(config.logger.winston);
const events = require('../events');

//mongoose.Promise = global.Promise; //use native promise for mongoose

exports.init = function(cb) {
    mongoose.connect(config.mongodb, {}, function(err) {
        if(err) return cb(err);
        logger.info("connected to mongo");
        cb();
    });
}
exports.disconnect = function(cb) {
    mongoose.disconnect(cb);
}

///////////////////////////////////////////////////////////////////////////////////////////////////

//workflow instance
var instanceSchema = mongoose.Schema({

    workflow_id: String, //"sca-wf-life"

    name: String, //name of the workflow
    desc: String, //desc of the workflow

    //user that this workflow instance belongs to
    user_id: {type: String, index: true}, 

    config: mongoose.Schema.Types.Mixed,

    create_date: {type: Date, default: Date.now },
    update_date: {type: Date, default: Date.now },
});
/*
{'fraction_non_alphanumeric': 0.22174473571121617, 'fraction_numerical': 0.0004297378599054577, 'mean_word_length': 2.459138187221397, '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': '6388821', 'n_tokens_mistral': 672, 'n_tokens_neox': 661, 'n_words': 182}