<commit_before>var mongoose = require('mongoose')
  , utils = require('connect').utils
  ;

exports.init = function(host, db) {
  mongoose.connect('mongodb://' + host + '/' + db);
};


var Schema = mongoose.Schema
  ;

function getAuthCookie() {
  return utils.uid(32);
}

exports.getAuthCookie = getAuthCookie;

var UserSchema = new Schema({
  username: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  authcookie: { type: String, required: true, default: getAuthCookie },
  created_at: { type: Date, default: Date.now },
  friendsList: [{type: String}],
  friendCount: {type: Number, required: true, default: 0}
});

UserSchema.methods.setPassword = function(password, <PASSWORD>) {
  if (password === <PASSWORD>) {
    this.password = password;
    return true;
  }
  this.invalidate('password_mismatch', new Error('Password mismatched'));
  return false;
};


/*
*  Adds a friend to the user's friend list.
   TODO: make it so when a friend is added a notification is created, and the other friends the other
   TODO:  Maybe make a friend request system? Blech
*/
UserSchema.methods.addfriend = function(user){
	//first check if user being added is in database
	/**
	if(this.friendCount == 100)
	{
		console.log("ERROR:  Cannot add any more friends to user " + this.username);
	}
	*/
	//console.log("DEBUG: Running last two lines");
	this.friendCount++;
	//this.friendsList[this.friendCount] = user;
	this.friendsList.push(user);
	//this.update({friendsList: this.friendsList});
}
exports.UserModel = mongoose.model('User', UserSchema);

var FileSchema = new Schema({
    filename: {type: String, required: true},
    filepath: {type: String, required: true, unique: true},
    uploaded_date: {type: Date, required: true, default: Date.now}
});

exports.FileModel = mongoose.model('File', FileSchema);

var FolderSchema = new Schema({
    folder_name: {type: String, required: true},
    files: {type: [Schema.Types.ObjectId], required: true}
});


var NotificationSchema = new Schema({
  type: { type: String, required: true },
  username: { type: String, required: true}, 
  friend: { type: String, required: true },
  group: { type: String },
  created_at: { type: Date, required: true, default: Date.now }
});

NotificationSchema.methods.clear = function(){};

exports.NotifModel = mongoose.model('Notification', NotificationSchema);

<commit_msg>Added default name for FolderSchema.<commit_after>var mongoose = require('mongoose')
  , utils = require('connect').utils
  ;

exports.init = function(host, db) {
  mongoose.connect('mongodb://' + host + '/' + db);
};


var Schema = mongoose.Schema
  ;

function getAuthCookie() {
  return utils.uid(32);
}

exports.getAuthCookie = getAuthCookie;

var UserSchema = new Schema({
  username: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  authcookie: { type: String, required: true, default: getAuthCookie },
  created_at: { type: Date, default: Date.now },
  friendsList: [{type: String}],
  friendCount: {type: Number, required: true, default: 0}
});

UserSchema.methods.setPassword = function(password, password2) {
  if (password === password2) {
    this.password = password;
    return true;
  }
  this.invalidate('password_mismatch', new Error('Password mismatched'));
  return false;
};


/*
*  Adds a friend to the user's friend list.
   TODO: make it so when a friend is added a notification is created, and the other friends the other
   TODO:  Maybe make a friend request system? Blech
*/
UserSchema.methods.addfriend = function(user){
	//first check if user being added is in database
	/**
	if(this.friendCount == 100)
	{
		console.log("ERROR:  Cannot add any more friends to user " + this.username);
	}
	*/
	//console.log("DEBUG: Running last two lines");
	this.friendCount++;
	//this.friendsList[this.friendCount] = user;
	this.friendsList.push(user);
	//this.update({friendsList: this.friendsList});
}
exports.UserModel = mongoose.model('User', UserSchema);

var FileSchema = new Schema({
    filename: {type: String, required: true},
    filepath: {type: String, required: true, unique: true},
    uploaded_date: {type: Date, required: true, default: Date.now}
});

exports.FileModel = mongoose.model('File', FileSchema);

var FolderSchema = new Schema({
    folder_name: {type: String, required: true, default : 'misc'},
    files: {type: [String], required: true}
});


var NotificationSchema = new Schema({
  type: { type: String, required: true },
  username: { type: String, required: true}, 
  friend: { type: String, required: true },
  group: { type: String },
  created_at: { type: Date, required: true, default: Date.now }
});

NotificationSchema.methods.clear = function(){};

exports.NotifModel = mongoose.model('Notification', NotificationSchema);


{'fraction_non_alphanumeric': 0.1447804473902237, 'fraction_numerical': 0.002899751449875725, 'mean_word_length': 4.395530726256983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4898104', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1491, 'n_words': 446}