payservedb 4.3.1 → 4.3.2

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.
package/index.js CHANGED
@@ -131,7 +131,8 @@ const models = {
131
131
  VasPayment: require('./src/models/vas_payments'),
132
132
  VasInvoicesQuickBooks: require('./src/models/vas_invoices_upload'),
133
133
  ServiceChargePayment: require('./src/models/service_charge_payments'),
134
- ServiceChargeInvoiceUpload: require('./src/models/service_charge_invoice_upload')
134
+ ServiceChargeInvoiceUpload: require('./src/models/service_charge_invoice_upload'),
135
+ Campaign: require('./src/models/campaigns')
135
136
 
136
137
  };
137
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,73 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const CampaignSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true,
8
+ },
9
+ name: {
10
+ type: String,
11
+ required: true,
12
+ trim: true,
13
+ maxlength: 100
14
+ },
15
+ objective: {
16
+ type: String,
17
+ enum: ['Brand Awareness', 'Lead Generation', 'Sales', 'Engagement'],
18
+ required: true
19
+ },
20
+ startDate: {
21
+ type: Date,
22
+ required: true
23
+ },
24
+ endDate: {
25
+ type: Date,
26
+ required: true,
27
+ validate: {
28
+ validator: function (value) {
29
+ return this.startDate <= value;
30
+ },
31
+ message: 'End date must be after or equal to start date'
32
+ }
33
+ },
34
+ targetAudience: {
35
+ type: String,
36
+ required: true,
37
+ trim: true,
38
+ maxlength: 200
39
+ },
40
+ channels: [{
41
+ type: String,
42
+ enum: ['Email', 'Social Media', 'SMS', 'Ads'],
43
+ required: true
44
+ }],
45
+ status: {
46
+ type: String,
47
+ enum: ['Draft', 'Ongoing', 'Completed'],
48
+ default: 'Draft'
49
+ }, description: {
50
+ type: String,
51
+ trim: true,
52
+ maxlength: 500
53
+ },
54
+ createdAt: {
55
+ type: Date,
56
+ default: Date.now
57
+ },
58
+ updatedAt: {
59
+ type: Date,
60
+ default: Date.now
61
+ }
62
+ }, {
63
+ timestamps: true
64
+ });
65
+
66
+ // Ensure at least one channel is selected
67
+ CampaignSchema.path('channels').validate(function (value) {
68
+ return value.length > 0;
69
+ }, 'At least one channel must be selected');
70
+
71
+ const Campaign = mongoose.model('Campaign', CampaignSchema);
72
+
73
+ module.exports =Campaign;