1234567891011121314151617181920212223 |
- var mongoose = require('mongoose');
- var Schema = mongoose.Schema;
- var SubscriberSchema = new Schema(
- {
- first_name: {type: String, required: false, maxLength: 100},
- last_name: {type: String, required: false, maxLength: 100},
- email: {type: String, required: true, maxLength: 100},
- confirmed_subscription: { type: Boolean, default: false },
- last_updated: { type: Date, default: Date.now() },
- registration_date: { type: Date, default: Date.now(), immutable: true },
- registration_attempts : { type: Number, default: 1 }
- }
- );
- SubscriberSchema.methods.attempted_registration = function attempted_registration() {
- this.registration_attempts += 1;
- this.last_updated = Date.now();
- };
- //Export model
- module.exports = mongoose.model('Subscriber', SubscriberSchema);
|