Comparing version 1.3.9 to 1.3.10
{ | ||
"name": "ab-models", | ||
"version": "1.3.9", | ||
"version": "1.3.10", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
var mongoose = require('../mongoose.js')(); | ||
var _ = require('lodash'); | ||
var crypto = require('crypto'); | ||
@@ -15,2 +16,6 @@ var schema = new mongoose.Schema({ | ||
email: String, | ||
unsubscribeToken: String, | ||
unsubscribed: { type: Boolean, default: false }, | ||
modified: { type: Date, default: Date.now }, | ||
@@ -20,2 +25,9 @@ created: { type: Date, default: Date.now } | ||
schema.pre('save', function(next) { | ||
if (this.isNew) { | ||
this.unsubscribeToken = crypto.randomBytes(16).toString('hex'); | ||
} | ||
next(); | ||
}); | ||
schema.virtual('id').get(function() { | ||
@@ -22,0 +34,0 @@ if (this._id) { |
12909
372