database-connector 2.2.9 → 2.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/models/Offer.js +36 -0
  2. package/package.json +1 -1
package/models/Offer.js CHANGED
@@ -58,6 +58,23 @@ const mongoose = require('mongoose');
58
58
  * type: string
59
59
  * enum: [percentage, amount]
60
60
  * description: Type of discount
61
+ * type:
62
+ * type: string
63
+ * enum: [followers, all, specific]
64
+ * default: all
65
+ * description: Who can see this offer
66
+ * userIds:
67
+ * type: array
68
+ * items:
69
+ * type: string
70
+ * description: Array of user IDs (used when type is 'specific')
71
+ * description:
72
+ * type: string
73
+ * description: Offer description
74
+ * addToSlider:
75
+ * type: boolean
76
+ * default: false
77
+ * description: Whether to add this offer to the slider
61
78
  * createdAt:
62
79
  * type: string
63
80
  * format: date-time
@@ -135,6 +152,23 @@ const OfferSchema = new mongoose.Schema(
135
152
  required: true,
136
153
  enum: ['percentage', 'amount'],
137
154
  },
155
+ type: {
156
+ type: String,
157
+ default: 'all',
158
+ enum: ['followers', 'all', 'specific'],
159
+ },
160
+ userIds: {
161
+ type: [mongoose.Schema.Types.ObjectId],
162
+ ref: 'User',
163
+ default: [],
164
+ },
165
+ description: {
166
+ type: String,
167
+ },
168
+ addToSlider: {
169
+ type: Boolean,
170
+ default: false,
171
+ },
138
172
  },
139
173
  {
140
174
  timestamps: true,
@@ -154,5 +188,7 @@ OfferSchema.index({ offerStatus: 1 });
154
188
  OfferSchema.index({ offerExpiration: 1 });
155
189
  OfferSchema.index({ createdAt: -1 });
156
190
  OfferSchema.index({ offerDeleted: 1 });
191
+ OfferSchema.index({ type: 1 });
192
+ OfferSchema.index({ userIds: 1 });
157
193
 
158
194
  module.exports = mongoose.model('Offer', OfferSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.2.9",
3
+ "version": "2.2.11",
4
4
  "description": "MongoDB models package with Mongoose schemas for e-commerce applications. Includes User, Product, Store, Order and more with built-in validation and virtual properties.",
5
5
  "main": "models/index.js",
6
6
  "scripts": {