<commit_before>/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
    env = process.env.NODE_ENV || 'development',
    config = require('../../config/config')[env],
    Schema = mongoose.Schema;



// Buyout Options Schema
var buyoutOptionsSchema = new Schema({
    name: {
        type: String,
        "default": ''
    },
    terms: [{}],
    costs: [costsSchema]
});

// Costs Schema
var costsSchema = new Schema({
    min: {
        type: Number,
        "default": ''
    },
    max: {
        type: Number,
        "default": ''
    },
    rates: [{}]
});



/**
 * Program Schema
 */
var ProgramSchema = new Schema({
    "created": {
        type: Date,
        "default": Date.now
    },
    name: {
        type: String,
        "default": ''
    },
    displayName: String,
    rateSheet: {
        termPeriod: {
            type: String,
            "default": ''
        },
        buyoutOptions: [buyoutOptionsSchema]
    }
});

/**
 * Statics
 */
ProgramSchema.statics = {
    load: function(id, cb) {
        this.findOne({
            _id: id
        }).exec(cb);
    }
};

ProgramSchema.pre('init', function(next, data) {

    //console.log('DATA IS...');
    //console.log(data);

    next();
});

mongoose.model('Program', ProgramSchema);<commit_msg>Refactor program schema to simplify.<commit_after>/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
    env = process.env.NODE_ENV || 'development',
    config = require('../../config/config')[env],
    Schema = mongoose.Schema; 

// Will add the Currency type to the Mongoose Schema types
//require('mongoose-currency').loadType(mongoose);
require('mongoose-currency').loadType(mongoose);
var Currency = mongoose.Types.Currency;

/**
 * Program Schema
 */
var ProgramSchema = new Schema({
    "created": {
        type: Date,
        "default": Date.now
    },
    name: {
        type: String,
        "default": ''
    },
    displayName: String,
    rateSheet: {
        termPeriod: {
            type: String,
            "default": ''
        },
        buyoutOptions: [{
            name: {
                type: String,
                "default": ''
            },
            terms: [],
            costs: [{
                min: {
                    type: Currency,
                    "default": 0
                },
                max: {
                    type: Currency,
                    "default": 0
                },
                rates: []
            }]
        }]
    }
});

/**
 * Statics
 */
ProgramSchema.statics = {
    load: function(id, cb) {
        this.findOne({
            _id: id
        }).exec(cb);
    }
};

ProgramSchema.pre('init', function(next, data) {
    next();
});

mongoose.model('Program', ProgramSchema);
{'fraction_non_alphanumeric': 0.15924719507781396, 'fraction_numerical': 0.0007238508867173362, 'mean_word_length': 1.6628131021194605, 'pattern_counts': {'":': 14, '<': 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': '6484449', 'n_tokens_mistral': 828, 'n_tokens_neox': 815, 'n_words': 170}