{"size": 877, "ext": "js", "max_stars_repo_path": "API-Node-BDama/models/user.js", "max_stars_repo_name": "sccesp96/udemy", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "API-Node-BDama/models/user.js", "max_issues_repo_name": "sccesp96/udemy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "API-Node-BDama/models/user.js", "max_forks_repo_name": "sccesp96/udemy", "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": 35.08, "max_line_length": 91, "alphanum_fraction": 0.669327252}
const mongoose = require('mongoose')
    // importo schema de mongoose que seria como una tabla creo
const Schema = mongoose.Schema
    // importo bcrypt para hashear el pass, hay que instalarlo con npm
const bcrypt = require('bcrypt-nodejs')

const UserSchema = ({
    email: { type: String, unique: true, required: true, lowercase: true },
    // select false , hace que al hacer un get con un select no pase el password
    password: { type: String, select: false, required: true },
    signupDate: { type: Date, default: Date.now(), required: true },
})

// UserSchema.pre('save', function(next) {

//     //creo la variable user y le doy el valor de this, que en este caso es el UserSchema
//     let user = this

//     if (!user.isModified('password')) return next()

//     //else 
//     bycryps.genSalt(10, )
// })

module.exports = mongoose.model('User', UserSchema)