database-connector 2.4.7 → 2.4.9

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.
@@ -28,11 +28,11 @@ const mongoose = require('mongoose');
28
28
  * description: Notification content
29
29
  * type:
30
30
  * type: string
31
- * enum: [order, offer]
31
+ * enum: [order, offer, subscription]
32
32
  * description: Type of notification
33
33
  * sub_type:
34
34
  * type: string
35
- * enum: [Delivery, Pickup, Reservation, Return, Refund, Cancel, offer, product]
35
+ * enum: [Delivery, Pickup, Reservation, Return, Refund, Cancel, offer, product, subscription_created, subscription_updated, expiry_reminder, payment_reminder, payment_reminder_manager, payment_locked, payment_locked_manager, upcoming_activated, subscription_ended]
36
36
  * default: Cancel
37
37
  * description: Sub-type of notification
38
38
  * seend:
@@ -60,42 +60,88 @@ const mongoose = require('mongoose');
60
60
  * createdAt: "2025-12-07T10:30:00.000Z"
61
61
  * updatedAt: "2025-12-07T10:30:00.000Z"
62
62
  */
63
- const NotificationSchema = new mongoose.Schema(
64
- {
65
- owner_id: {
66
- type: mongoose.Schema.Types.ObjectId,
67
- ref: 'User',
68
- required: true,
69
- },
70
- title: {type: String, required: true },
71
- content: {type: String, required: true },
72
- id: {type: String, required: true },
73
- type: { type: String, required: true, enum: [
74
- 'order',
75
- 'offer',
76
- ], default: '' },
77
- sub_type: { type: String, required: true, enum: [
78
- 'Delivery',
79
- 'Pickup',
80
- 'Reservation',
81
- 'Return',
82
- 'Refund',
83
- 'Cancel' ,
84
- 'offer',
85
- 'product'
86
- ], default: 'Cancel'
87
- },
88
- seend: { type: Boolean, default: false },
89
- seendInList: { type: Boolean, default: false }
63
+ const NotificationSchema = new mongoose.Schema({
64
+ owner_id: {
65
+ type: mongoose.Schema.Types.ObjectId,
66
+ ref: 'User',
67
+ required: true,
90
68
  },
91
- { timestamps: true }
92
- );
69
+ title: {
70
+ type: String,
71
+ required: true
72
+ },
73
+ content: {
74
+ type: String,
75
+ required: true
76
+ },
77
+ id: {
78
+ type: String,
79
+ required: true
80
+ },
81
+ type: {
82
+ type: String,
83
+ required: true,
84
+ enum: [
85
+ 'order',
86
+ 'offer',
87
+ 'subscription'
88
+ ],
89
+ default: ''
90
+ },
91
+ sub_type: {
92
+ type: String,
93
+ required: true,
94
+ enum: [
95
+ 'Delivery',
96
+ 'Pickup',
97
+ 'Reservation',
98
+ 'Return',
99
+ 'Refund',
100
+ 'Cancel',
101
+ 'offer',
102
+ 'product',
103
+ 'subscription_created',
104
+ 'subscription_updated',
105
+ 'expiry_reminder',
106
+ 'payment_reminder',
107
+ 'payment_reminder_manager',
108
+ 'payment_locked',
109
+ 'payment_locked_manager',
110
+ 'upcoming_activated',
111
+ 'subscription_ended'
112
+ ],
113
+ default: 'Cancel'
114
+ },
115
+ seend: {
116
+ type: Boolean,
117
+ default: false
118
+ },
119
+ seendInList: {
120
+ type: Boolean,
121
+ default: false
122
+ }
123
+ }, {
124
+ timestamps: true
125
+ });
93
126
 
94
127
  // Indexes for performance optimization
95
- NotificationSchema.index({ owner_id: 1, createdAt: -1 });
96
- NotificationSchema.index({ owner_id: 1, seend: 1 });
97
- NotificationSchema.index({ owner_id: 1, seendInList: 1 });
98
- NotificationSchema.index({ type: 1 });
99
- NotificationSchema.index({ sub_type: 1 });
128
+ NotificationSchema.index({
129
+ owner_id: 1,
130
+ createdAt: -1
131
+ });
132
+ NotificationSchema.index({
133
+ owner_id: 1,
134
+ seend: 1
135
+ });
136
+ NotificationSchema.index({
137
+ owner_id: 1,
138
+ seendInList: 1
139
+ });
140
+ NotificationSchema.index({
141
+ type: 1
142
+ });
143
+ NotificationSchema.index({
144
+ sub_type: 1
145
+ });
100
146
 
101
147
  module.exports = mongoose.model('Notification', NotificationSchema);
@@ -19,6 +19,7 @@ const buildSubscriptionHistorySnapshot = (subscriptionDoc) => ({
19
19
  startDate: subscriptionDoc.startDate,
20
20
  endDate: subscriptionDoc.endDate,
21
21
  notes: subscriptionDoc.notes,
22
+ createdAt: new Date(),
22
23
  });
23
24
 
24
25
  const recordSubscriptionHistory = async (subscriptionDoc) => {
@@ -323,6 +324,10 @@ const subscriptionSchema = new mongoose.Schema(
323
324
  type: String,
324
325
  default: null,
325
326
  },
327
+ createdAt: {
328
+ type: Date,
329
+ default: Date.now,
330
+ },
326
331
  },
327
332
  ],
328
333
  upcomingSubscriptions: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.4.7",
3
+ "version": "2.4.9",
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": {