// get an instance of mongoose and mongoose.Schema
var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var userSchema = new Schema({
    nome: { type: String, required: true },
    cognome: { type: String, required: true },
    matricola: { type: Number, unique: true, required: true },
    email: String,
    username: { type: String, unique: true },
    password: String,
    admin: { type: Boolean, default: false }
});

// custom method to add string to end of name
// you can create more important methods like name validations or formatting
// you can also do queries and find similar users 
userSchema.methods.emailify = function () {
    // add some stuff to the users name
    //TODO controllo se è uno studente (@studenti...) o admin/professore
    this.email = this.username + '@unims.it';

    return this.email;
};

// set up a mongoose model and pass it using module.exports
var User = mongoose.model('User', userSchema);
module.exports = User;
@@ -309,24 +309,82 @@
 ail: String,
+ %0A    emailUniversitaria: String, %0A    telefono:  Number, 
 %0A    usernam
@@ -490,16 +490,17 @@
  %7D%0A%7D);%0A%0A
+%0A
 // custo
@@ -868,17 +868,16 @@
 ms.it';%0A
-%0A
     retu

modifica schema