const mongoose = require('mongoose') const userSchema = new mongoose.Schema({ name: { type: String }, email: { type: String, required: true }, password: { type: String, required: true }, role: { type: String }, tokens: [{ token: { type: String, required: true } }] }) // userSchema.pre('save', async function(next) { // const user = this // console.log('pre hash: ' + user.password) // user.password = await bcrypt.hash(user.password, 8) // console.log('posle hash: ' + user.password) // console.log('Middleware before password hash') // next() // }) const User = mongoose.model('User', userSchema) module.exports = User