Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // User file
- var mongoose = require('mongoose')
- var Schema = mongoose.Schema
- var bcrypt = require('bcrypt-nodejs')
- var UserSchema = new Schema({
- username: {
- type: String
- },
- email: {
- type: String,
- },
- password: {
- type: String
- },
- ethAddress: {
- type: String
- },
- privateKey: {
- type: String
- },
- transactions: [{
- type: mongoose.Schema.Types.ObjectId,
- ref: 'Transactions'
- }]
- })
- UserSchema.pre('save', function(next){
- var user = this;
- bcrypt.hash(user.password, null, null, function(err,hash){
- if(err) return next(err)
- user.password = hash
- next()
- })
- })
- module.exports = mongoose.model('User', UserSchema);
- // Transaction File
- var mongoose = require('mongoose')
- var Schema = mongoose.Schema
- var bcrypt = require('bcrypt-nodejs')
- var TransactionSchema = new Schema({
- time: {
- type: String
- },
- date : {
- type: String
- },
- transactionType : {
- type: String
- },
- email : {
- type: String
- },
- amount: {
- type: String
- },
- txHash:{
- type: String
- }
- });
- module.exports = mongoose.model('Transactions', TransactionSchema);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement