subscriber.js 794 B

1234567891011121314151617181920212223
  1. var mongoose = require('mongoose');
  2. var Schema = mongoose.Schema;
  3. var SubscriberSchema = new Schema(
  4. {
  5. first_name: {type: String, required: false, maxLength: 100},
  6. last_name: {type: String, required: false, maxLength: 100},
  7. email: {type: String, required: true, maxLength: 100},
  8. confirmed_subscription: { type: Boolean, default: false },
  9. last_updated: { type: Date, default: Date.now() },
  10. registration_date: { type: Date, default: Date.now(), immutable: true },
  11. registration_attempts : { type: Number, default: 1 }
  12. }
  13. );
  14. SubscriberSchema.methods.attempted_registration = function attempted_registration() {
  15. this.registration_attempts += 1;
  16. this.last_updated = Date.now();
  17. };
  18. //Export model
  19. module.exports = mongoose.model('Subscriber', SubscriberSchema);