{"size": 842, "ext": "js", "max_stars_repo_path": "app/models/Role.js", "max_stars_repo_name": "wmzy/hiskyCrm", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/models/Role.js", "max_issues_repo_name": "wmzy/hiskyCrm", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/models/Role.js", "max_forks_repo_name": "wmzy/hiskyCrm", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 11.6944444444, "max_line_length": 64, "alphanum_fraction": 0.5973871734}

/**
 * Module dependencies.
 */

var mongoose = require('mongoose');

var Schema = mongoose.Schema;

/**
 * Role Schema
 */

var RoleSchema = new Schema({
	name: {type: String, required: true, unique: true, trim: true},
	description: {type: String, default: ''}
});

/**
 * Setters
 */


/**
 * Virtuals
 */


/**
 * Validations
 */

RoleSchema.path('name').validate(function (name) {
	return name.length;
}, 'Name cannot be blank');

/**
 * Pre-save hook
 */


/**
 * Methods
 */

RoleSchema.methods = {};

/**
 * Statics
 */

RoleSchema.statics = {

	/**
	 * Load
	 *
	 * @param {Object} options
	 * @param {Function} cb
	 * @api private
	 */

	load: function (options, cb) {
		options.select = options.select || 'name';
		this.findOne(options.criteria)
			.select(options.select)
			.exec(cb);
	}
};

mongoose.model('Role', RoleSchema);

