{"size": 1055, "ext": "js", "max_stars_repo_path": "src/models/authorModel.js", "max_stars_repo_name": "Saurabhvishv/Project_1", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/models/authorModel.js", "max_issues_repo_name": "Saurabhvishv/Project_1", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/models/authorModel.js", "max_forks_repo_name": "Saurabhvishv/Project_1", "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": 23.9772727273, "max_line_length": 105, "alphanum_fraction": 0.4853080569}
const mongoose = require("mongoose");


var validateEmail = function(email) {
    var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    return re.test(email)
};



const authorSchema = new mongoose.Schema({
     fname: { 
        type: String,
        required: 'first name is required'
    },
     lname: {
        type: String,
        required: 'last name is required'
     },
      title: {   
        required: true,
         type: String, enum: [ 'Mr' , 'Mrs', 'Miss'] 
        },
        email: {
            type: String,
            trim: true,
            lowercase: true,
            unique: true,
            required: 'Email address is required',
            validate: [validateEmail, 'Please fill a valid email address'],
            match: [/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/, 'Please fill a valid email address']
        },
        password: {
            type: String,
            required: 'passward is required'
        } 
    },  { timestamps: true})


module.exports = mongoose.model('myauthor', authorSchema)



