Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose');
- var bcrypt = require('bcrypt-nodejs');
- var buyerSchema = new mongoose.Schema({
- local: {
- name: { type: String },
- email : { type: String, require: true, unique: true },
- password: { type: String, require:true },
- dob:{type:Date},
- mobile_number:{type:String},
- shipping_address:{type:Object},
- billing_address:{type:Object},
- isLoggedIn : Number
- },
- facebook: {
- id : { type: String },
- token : { type: String },
- email : { type: String },
- name : { type: String }
- },
- twitter: {
- id : { type: String },
- token : { type: String },
- displayName : { type: String },
- username : { type: String }
- }
- });
- // Generate a hash
- buyerSchema.methods.generateHash = function(password) {
- return bcrypt.hashSync(password, brcypt.genSaltSync(8), null);
- };
- // Check if password is valid
- buyerSchema.methods.validPassword = function(password) {
- return bcrypt.compareSync(password, this.local.password);
- };
- var Buyer = mongoose.model('Buyer',buyerSchema);
- module.exports = Buyer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement