database-connector 2.2.9 → 2.2.10

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 +22 -0
  2. package/package.json +1 -1
package/models/Offer.js CHANGED
@@ -58,6 +58,16 @@ 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')
61
71
  * createdAt:
62
72
  * type: string
63
73
  * format: date-time
@@ -135,6 +145,16 @@ const OfferSchema = new mongoose.Schema(
135
145
  required: true,
136
146
  enum: ['percentage', 'amount'],
137
147
  },
148
+ type: {
149
+ type: String,
150
+ default: 'all',
151
+ enum: ['followers', 'all', 'specific'],
152
+ },
153
+ userIds: {
154
+ type: [mongoose.Schema.Types.ObjectId],
155
+ ref: 'User',
156
+ default: [],
157
+ },
138
158
  },
139
159
  {
140
160
  timestamps: true,
@@ -154,5 +174,7 @@ OfferSchema.index({ offerStatus: 1 });
154
174
  OfferSchema.index({ offerExpiration: 1 });
155
175
  OfferSchema.index({ createdAt: -1 });
156
176
  OfferSchema.index({ offerDeleted: 1 });
177
+ OfferSchema.index({ type: 1 });
178
+ OfferSchema.index({ userIds: 1 });
157
179
 
158
180
  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.10",
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": {