I'm building an application with express framework and I want to set a default subscription period to user when get registered ( 6 months by default for example ), after that period, user must pay a specific amount to get access to the app, can some one explain or help by technicals ideas ?
const mongoose = require('mongoose');
const schema = new mongoose.Schema({
email: {
type: String,
unique: true,
required: true
},
passwordHash: {
type: String,
required: true
},
title: {
type: String,
required: true
},
firstName: {
type: String,
required: true
},
lastName: {
type: String,
required: true
},
phone: {
type: String,
required: true
},
acceptTerms: Boolean,
subscriptionPeriod:{
type: Number,
default: 6
},
payed:{
type:Boolean,
default: true
},
role: {
type: String,
required: true
},
verificationToken: String,
verified: Date,
resetToken: {
token: String,
expires: Date
},
passwordReset: Date,
created: {
type: Date,
default: Date.now
},
updated: Date
});
schema.virtual('isVerified').get(function() {
return !!(this.verified || this.passwordReset);
});
module.exports = mongoose.model('User', schema);