endpoint usuario y compras

This commit is contained in:
2021-04-18 20:24:56 -05:00
parent 4766d0ef3c
commit 4a7fb24eb2
13 changed files with 12114 additions and 1 deletions

22
models/user.js Executable file
View File

@@ -0,0 +1,22 @@
const mongoose = require('mongoose');
const {Schema} =mongoose;
const bscryptjs = require('bcrypt');
const UserSchema=new Schema({
name: {type:String,required:true},
email: {type:String, required:true},
password:{type:String, required:true},
date: {type: Date, default: Date.now}
});
UserSchema.methods.encryptPassword = async (password)=>{
const salt=await bscryptjs.genSalt(10);
const hash=await bscryptjs.hash(password,salt);
return hash;
};
UserSchema.methods.matchPassword=async function (password){
return await bscryptjs.compare(password,this.password);
};
const User = mongoose.model('Users',UserSchema);
export default User;