<commit_before>'use strict';

var mongoose = require('mongoose'),
	 Schema = mongoose.Schema;

var UserSchema = new Schema ({
	firstName: String,
	lastName: String,
	email: {
		type: String,
	 	index: true,
	 	match: /.+\@.+\..+/,
		required: true
	 },
 	username: String,
	password: {
		type: String,	  
	 	validate: [
		  function(password){
				return password.length >=8
		  },
	 		'password shall be at least 8 characters long'
		],
	},
	role: {
		type: String,
	 	enum: ['admin', 'owner', 'user' ]
	},
	created: {
		type: Date,
		default: Date.now
	}
});

UserSchema.methods.authenticate = function(password){
	return this.password === password;
}

UserSchema.set('toJSON', {<commit_msg>indexes introduced in mongoose schema after initial data population are not reflected in mongodb<commit_after>'use strict';

var mongoose = require('mongoose'),
	 Schema = mongoose.Schema;

var UserSchema = new Schema ({
	firstName: String,
	lastName: String,
	email: {
		type: String,
	 	index: true,
		unique: true,
	 	match: /.+\@.+\..+/,
		required: true
	 },
	website:{
		type: String,
		set: function(url){
			if (!url) {
				return url;
			} else {
				if (url.indexOf('http://') !==0 && 
						url.indexOf('https://') !==0){
								url = ['http://', url].join('');
						}
				return url;
			}
		}
	},
 	username: String,
	password: {
		type: String,	  
	 	validate: [
		  function(password){
				return password.length >=8
		  },
	 		'password shall be at least 8 characters long'
		],
		get: function(pass) {
				return(['!',pass].join('_'));
		},
	},
	role: {
		type: String,
	 	enum: ['admin', 'owner', 'user' ]
	},
	created: {
		type: Date,
		default: Date.now
	},
	soc:{
		type: String,
		unique: true,
	}

});

UserSchema.virtual('fullName').get(function(){
	return [this.firstName, this.lastName].join(' ');
});

UserSchema.methods.authenticate = function(password){
	return this.password === password;
}

UserSchema.set('toJSON', {
{'fraction_non_alphanumeric': 0.17559217301750774, 'fraction_numerical': 0.003089598352214212, 'mean_word_length': 3.1695278969957084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '7282319', 'n_tokens_mistral': 770, 'n_tokens_neox': 673, 'n_words': 165}