Skip to content

Commit dea2bf7

Browse files
committed
feat(api): added schema for rewards
1 parent 4784d8a commit dea2bf7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/models/schemas/System.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,33 @@ const SystemSchema = new Schema({
8484
},
8585
},
8686
],
87+
rewards: [
88+
{
89+
_id: { type: String, required: true, unique: true }, // Unique code like "SUMMER2025"
90+
type: { type: String, enum: ['giftcard', 'coupon', 'voucher'], required: true },
91+
description: String,
92+
discount: {
93+
type: { type: String, enum: ['percentage', 'fixed'], required: true },
94+
value: { type: Number, required: true }, // e.g., 20 for 20% or $20
95+
},
96+
appliesTo: {
97+
plans: [String], // Array of plan IDs it can be applied to, if any
98+
roles: [String], // Optionally apply by role
99+
},
100+
usage: {
101+
maxRedemptions: { type: Number, default: 1 }, // How many times this code can be used globally
102+
usedBy: [
103+
{
104+
userId: String,
105+
redeemedAt: Date,
106+
},
107+
],
108+
},
109+
validFrom: Date,
110+
validUntil: Date,
111+
isActive: { type: Boolean, default: true },
112+
},
113+
],
87114
});
88115

89116
export default model('System', SystemSchema);

0 commit comments

Comments
 (0)