var mongoose = require('mongoose'); var express = require('express'); var bodyParser = require('body-parser'); const {ObjectID} = require('mongodb'); var _ = require('lodash');
UserSchema.methods.toJSON = function () { var user = this; var userObject = user.toObject();
return _.pick(userObject, ['_id', 'email']); };
UserSchema.methods.generateAuthToken = function () { var user = this; var access = 'auth'; var token = jwt.sign({_id: user._id.toHexString(), access}, 'abc123').toString();