Skip to content

Commit

Permalink
Added req_consumed to count exhausted quotas
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrea committed Jul 10, 2024
1 parent 990fea7 commit eedd25b
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/models/schemas/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const UserSchema = new mongoose.Schema({
* @type {number}
* @default 500
*/
req_quota: { type: Number, default: 500 },
req_quota: { type: Number, required: true, default: 500 },

/**
* Number of requests made by the user.
Expand All @@ -85,6 +85,13 @@ const UserSchema = new mongoose.Schema({
*/
req_count: { type: Number, default: 0 },

/**
* Number of requests consumed by the user.
* @type {number}
* @default 0
*/
req_consumed: { type: Number, default: 0 },

/**
* Date and time when the user account was created.
* @type {Date}
Expand All @@ -108,6 +115,42 @@ const UserSchema = new mongoose.Schema({
* @default ['user']
*/
roles: { type: [String], default: ['user'] },

/**
* Subscription or plan type.
* @type {string}
*/
planType: { type: String, default: 'free' },

/**
* Subscription start date.
* @type {Date}
*/
subscriptionStart: { type: Date },

/**
* Subscription end date.
* @type {Date}
*/
subscriptionEnd: { type: Date },

/**
* Subscription status.
* @type {string}
* @enum ['active', 'expired', 'canceled', 'pending', 'suspended', 'trial', 'renewal due', 'grace period']
* @default 'active'
*/
subscriptionStatus: {
type: String,
enum: ['active', 'expired', 'canceled', 'pending', 'suspended', 'trial', 'renewal due', 'grace period'],
default: 'active',
},

/**
* Metadata for subscription.
* @type {object}
*/
subscriptionMetadata: { type: Object },
});

/**
Expand Down

0 comments on commit eedd25b

Please sign in to comment.