<commit_before>/*jslint eqeq: true, indent: 2, node: true, plusplus: true, regexp: true, unparam: true, vars: true, nomen: true */
'use strict';

/*!
The data layer for Neuola.
===========================

Most of the models are based on the structure defined by Mongoose.js ODM.
This is the entrance of the module.

@author yfwz100
*/

var mongoose = require('mongoose');

/**
 * The exported configuration function. It's a wrapper around mongoose.connect() but the settings can be written in a parameter, like
 *
 * {
 *   uri: ... ,
 *   user: ... ,
 *   pass: ...
 * }
 *
 * @see http://mongoosejs.com/docs/connections.html
 */
module.exports = function (uri, config) {
  if (config) {
    config = uri;
    uri = config.uri;
  }
  mongoose.connect(uri, config);
};

// Define the model based on name convention.
function defineModel(name) {
  var schema = require('./model/' + name);
  module.exports[name] = mongoose.model(name, schema);
  return module.exports[name];
}

// The article model, belonged to one or more catalog.
defineModel('Post');

// The catalog model, containing articles.
defineModel('Catalog');

// The message model.
defineModel('Message');<commit_msg>Return model after configuration.<commit_after>/*jslint eqeq: true, indent: 2, node: true, plusplus: true, regexp: true, unparam: true, vars: true, nomen: true */
'use strict';

/*!
The data layer for Neuola.
===========================

Most of the models are based on the structure defined by Mongoose.js ODM.
This is the entrance of the module.

@author yfwz100
*/

var mongoose = require('mongoose');

/**
 * The exported configuration function. It's a wrapper around mongoose.connect() but the settings can be written in a parameter, like
 *
 * {
 *   uri: ... ,
 *   user: ... ,
 *   pass: ...
 * }
 *
 * @see http://mongoosejs.com/docs/connections.html
 */
function model(uri, config) {
  if (config) {
    config = uri;
    uri = config.uri;
  }
  mongoose.connect(uri, config);
  return model;
}
module.exports = model;

// Define the model based on name convention.
function defineModel(name) {
  var schema = require('./model/' + name);
  model[name] = mongoose.model(name, schema);
  return model[name];
}

// The article model, belonged to one or more catalog.
defineModel('Post');

// The catalog model, containing articles.
defineModel('Catalog');

// The message model.
defineModel('Message');
{'fraction_non_alphanumeric': 0.1590623691921306, 'fraction_numerical': 0.0033486814566764337, 'mean_word_length': 3.631782945736434, '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': '4831309', 'n_tokens_mistral': 737, 'n_tokens_neox': 732, 'n_words': 251}