codebase-models 2.0.0 → 2.0.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.
Files changed (142) hide show
  1. package/dist/src/models/Announcement.d.ts +1 -3
  2. package/dist/src/models/Announcement.js +1 -1
  3. package/dist/src/models/AppEvent.d.ts +1 -3
  4. package/dist/src/models/AppEvent.js +1 -1
  5. package/dist/src/models/Audience.d.ts +1 -3
  6. package/dist/src/models/Audience.js +1 -1
  7. package/dist/src/models/BqPreCompiledData.d.ts +1 -3
  8. package/dist/src/models/BqPreCompiledData.js +1 -1
  9. package/dist/src/models/CVRReport.d.ts +1 -3
  10. package/dist/src/models/CVRReport.js +1 -2
  11. package/dist/src/models/Client.d.ts +1 -3
  12. package/dist/src/models/Client.js +1 -1
  13. package/dist/src/models/ClientAdditionalRevenue.d.ts +1 -3
  14. package/dist/src/models/ClientAdditionalRevenue.js +1 -1
  15. package/dist/src/models/ClientLearning.d.ts +1 -3
  16. package/dist/src/models/ClientLearning.js +1 -1
  17. package/dist/src/models/ClientLinks.d.ts +1 -3
  18. package/dist/src/models/ClientLinks.js +1 -1
  19. package/dist/src/models/ClientNextSteps.d.ts +1 -3
  20. package/dist/src/models/ClientNextSteps.js +1 -1
  21. package/dist/src/models/ClientNote.d.ts +1 -3
  22. package/dist/src/models/ClientNote.js +1 -1
  23. package/dist/src/models/ClientReportsTemp.d.ts +1 -3
  24. package/dist/src/models/ClientReportsTemp.js +1 -3
  25. package/dist/src/models/ClientRetention.d.ts +1 -3
  26. package/dist/src/models/ClientRetention.js +1 -3
  27. package/dist/src/models/ClientScript.d.ts +1 -3
  28. package/dist/src/models/ClientScript.js +1 -2
  29. package/dist/src/models/ClientStrategy.d.ts +1 -3
  30. package/dist/src/models/ClientStrategy.js +1 -1
  31. package/dist/src/models/ClientSurvay.d.ts +1 -7
  32. package/dist/src/models/ClientSurvay.js +1 -1
  33. package/dist/src/models/Environment.d.ts +1 -3
  34. package/dist/src/models/Environment.js +1 -5
  35. package/dist/src/models/Faqs.d.ts +1 -3
  36. package/dist/src/models/Faqs.js +1 -1
  37. package/dist/src/models/Feedback.d.ts +1 -3
  38. package/dist/src/models/Feedback.js +1 -1
  39. package/dist/src/models/Goal.d.ts +1 -3
  40. package/dist/src/models/Goal.js +1 -4
  41. package/dist/src/models/Hypothesis.d.ts +1 -3
  42. package/dist/src/models/Hypothesis.js +1 -5
  43. package/dist/src/models/HypothesisSheet.d.ts +1 -3
  44. package/dist/src/models/HypothesisSheet.js +1 -1
  45. package/dist/src/models/LandingPages.d.ts +1 -3
  46. package/dist/src/models/LandingPages.js +1 -6
  47. package/dist/src/models/NewIdeas.d.ts +1 -3
  48. package/dist/src/models/NewIdeas.js +1 -1
  49. package/dist/src/models/Notification.d.ts +1 -3
  50. package/dist/src/models/Notification.js +1 -1
  51. package/dist/src/models/Organization.d.ts +1 -3
  52. package/dist/src/models/Organization.js +1 -1
  53. package/dist/src/models/Page.d.ts +1 -3
  54. package/dist/src/models/Page.js +1 -8
  55. package/dist/src/models/PageElement.d.ts +1 -3
  56. package/dist/src/models/PageElement.js +1 -5
  57. package/dist/src/models/PageTestType.d.ts +1 -3
  58. package/dist/src/models/PageTestType.js +1 -1
  59. package/dist/src/models/Portfolio.d.ts +1 -3
  60. package/dist/src/models/Portfolio.js +1 -1
  61. package/dist/src/models/PrecalculationFilters.d.ts +1 -3
  62. package/dist/src/models/PrecalculationFilters.js +2 -1
  63. package/dist/src/models/QueryLog.d.ts +1 -3
  64. package/dist/src/models/QueryLog.js +1 -1
  65. package/dist/src/models/ReadNotification.d.ts +1 -3
  66. package/dist/src/models/ReadNotification.js +1 -1
  67. package/dist/src/models/Report.d.ts +1 -3
  68. package/dist/src/models/Report.js +1 -1
  69. package/dist/src/models/Role.d.ts +1 -3
  70. package/dist/src/models/Role.js +1 -1
  71. package/dist/src/models/SavedSegment.d.ts +1 -3
  72. package/dist/src/models/SavedSegment.js +1 -1
  73. package/dist/src/models/Segment.d.ts +1 -3
  74. package/dist/src/models/Segment.js +1 -1
  75. package/dist/src/models/SegmentCombination.d.ts +1 -3
  76. package/dist/src/models/SegmentCombination.js +1 -1
  77. package/dist/src/models/Snippet.d.ts +1 -3
  78. package/dist/src/models/Snippet.js +1 -5
  79. package/dist/src/models/StageInCustomerJourney.d.ts +1 -3
  80. package/dist/src/models/StageInCustomerJourney.js +1 -1
  81. package/dist/src/models/Tag.d.ts +1 -3
  82. package/dist/src/models/Tag.js +1 -1
  83. package/dist/src/models/Temp.d.ts +1 -3
  84. package/dist/src/models/Temp.js +1 -1
  85. package/dist/src/models/Test.d.ts +1 -3
  86. package/dist/src/models/Test.js +1 -1
  87. package/dist/src/models/TestSequentialValue.d.ts +1 -3
  88. package/dist/src/models/TestSequentialValue.js +1 -1
  89. package/dist/src/models/Tier.d.ts +1 -3
  90. package/dist/src/models/Tier.js +1 -1
  91. package/dist/src/models/Trigger.d.ts +1 -3
  92. package/dist/src/models/Trigger.js +1 -1
  93. package/dist/src/models/User.d.ts +1 -3
  94. package/dist/src/models/User.js +1 -1
  95. package/package.json +1 -1
  96. package/src/models/Announcement.ts +1 -1
  97. package/src/models/AppEvent.ts +1 -1
  98. package/src/models/Audience.ts +1 -1
  99. package/src/models/BqPreCompiledData.ts +1 -1
  100. package/src/models/CVRReport.ts +1 -2
  101. package/src/models/Client.ts +1 -1
  102. package/src/models/ClientAdditionalRevenue.ts +1 -1
  103. package/src/models/ClientLearning.ts +1 -1
  104. package/src/models/ClientLinks.ts +1 -1
  105. package/src/models/ClientNextSteps.ts +1 -1
  106. package/src/models/ClientNote.ts +1 -1
  107. package/src/models/ClientReportsTemp.ts +1 -3
  108. package/src/models/ClientRetention.ts +1 -3
  109. package/src/models/ClientScript.ts +1 -2
  110. package/src/models/ClientStrategy.ts +1 -1
  111. package/src/models/ClientSurvay.ts +1 -1
  112. package/src/models/Environment.ts +2 -6
  113. package/src/models/Faqs.ts +1 -1
  114. package/src/models/Feedback.ts +1 -1
  115. package/src/models/Goal.ts +1 -4
  116. package/src/models/Hypothesis.ts +1 -5
  117. package/src/models/HypothesisSheet.ts +1 -1
  118. package/src/models/LandingPages.ts +1 -6
  119. package/src/models/NewIdeas.ts +1 -1
  120. package/src/models/Notification.ts +1 -1
  121. package/src/models/Organization.ts +1 -1
  122. package/src/models/Page.ts +4 -8
  123. package/src/models/PageElement.ts +1 -5
  124. package/src/models/PageTestType.ts +1 -1
  125. package/src/models/Portfolio.ts +1 -1
  126. package/src/models/PrecalculationFilters.ts +2 -1
  127. package/src/models/QueryLog.ts +1 -1
  128. package/src/models/ReadNotification.ts +1 -1
  129. package/src/models/Report.ts +1 -1
  130. package/src/models/Role.ts +1 -1
  131. package/src/models/SavedSegment.ts +1 -1
  132. package/src/models/Segment.ts +1 -1
  133. package/src/models/SegmentCombination.ts +1 -1
  134. package/src/models/Snippet.ts +1 -5
  135. package/src/models/StageInCustomerJourney.ts +1 -1
  136. package/src/models/Tag.ts +1 -1
  137. package/src/models/Temp.ts +1 -1
  138. package/src/models/Test.ts +1 -1
  139. package/src/models/TestSequentialValue.ts +1 -1
  140. package/src/models/Tier.ts +1 -1
  141. package/src/models/Trigger.ts +1 -1
  142. package/src/models/User.ts +1 -1
@@ -26,7 +26,6 @@ const ClientRetentionSchema = new Schema<IClientRetention>(
26
26
  type: mongoose.Schema.Types.ObjectId,
27
27
  ref: "client",
28
28
  required: true,
29
- index: true,
30
29
  },
31
30
  viewId: {
32
31
  type: String,
@@ -36,7 +35,6 @@ const ClientRetentionSchema = new Schema<IClientRetention>(
36
35
  type: Number,
37
36
  required: true,
38
37
  default: new Date().getFullYear(),
39
- index: true,
40
38
  },
41
39
  retentions: {
42
40
  type: [
@@ -101,7 +99,7 @@ ClientRetentionSchema.index(
101
99
  // Index for sorting by retainer value
102
100
  ClientRetentionSchema.index({ "retentions.retainerValue": -1 });
103
101
 
104
- const ClientRetention = model<IClientRetention>(
102
+ const ClientRetention = mongoose.models.clientretention || model<IClientRetention>(
105
103
  "ClientRetention",
106
104
  ClientRetentionSchema
107
105
  );
@@ -49,7 +49,6 @@ const ClientScriptSchema = new Schema<IClientScript>(
49
49
  client: {
50
50
  type: mongoose.Schema.Types.ObjectId,
51
51
  ref: "client",
52
- index: true,
53
52
  },
54
53
  viewId: {
55
54
  type: String,
@@ -176,6 +175,6 @@ ClientScriptSchema.index({ tracker_url: 1 }, { sparse: true });
176
175
  ClientScriptSchema.index({ asset_url: 1 }, { sparse: true });
177
176
 
178
177
 
179
- const ClientScript = model<IClientScript>("clientscript", ClientScriptSchema);
178
+ const ClientScript = mongoose.models.clientscript || model<IClientScript>("clientscript", ClientScriptSchema);
180
179
 
181
180
  export default ClientScript;
@@ -64,7 +64,7 @@ ClientStrategySchema.index({
64
64
  viewId: 1,
65
65
  });
66
66
 
67
- const ClientStrategy = model<IClientStrategy>(
67
+ const ClientStrategy = mongoose.models.clientstrategy || model<IClientStrategy>(
68
68
  "clientstrategy",
69
69
  ClientStrategySchema
70
70
  );
@@ -38,5 +38,5 @@ const ClientSurveySchema = new Schema<IClientSurvay>(
38
38
  }
39
39
  );
40
40
 
41
- const ClientSurvey = model("clientsurvey", ClientSurveySchema);
41
+ const ClientSurvey = mongoose.models.clientsurvey || model("clientsurvey", ClientSurveySchema);
42
42
  export default ClientSurvey;
@@ -14,18 +14,15 @@ const EnvironmentSchema = new Schema<IEnvironment>({
14
14
  required: true,
15
15
  default: 'Default',
16
16
  trim: true,
17
- index: true,
18
17
  },
19
18
  client: {
20
19
  type: mongoose.Schema.Types.ObjectId,
21
20
  ref: "client",
22
21
  required: true,
23
- index: true,
24
22
  },
25
23
  organizationId: {
26
24
  type: mongoose.Schema.Types.ObjectId,
27
25
  ref: "organization",
28
- index: true,
29
26
  },
30
27
  rules_js: {
31
28
  type: String,
@@ -35,8 +32,7 @@ const EnvironmentSchema = new Schema<IEnvironment>({
35
32
  isActive: {
36
33
  type: Boolean,
37
34
  default: true,
38
- index: true,
39
- }
35
+ }
40
36
  }, {
41
37
  timestamps: true
42
38
  });
@@ -52,6 +48,6 @@ EnvironmentSchema.index({ organizationId: 1, name: 1 }, {
52
48
  // Text index for full-text search
53
49
  EnvironmentSchema.index({ name: 'text' });
54
50
 
55
- const Environment = model<IEnvironment>("environment", EnvironmentSchema);
51
+ const Environment = mongoose.models.environment || model<IEnvironment>("environment", EnvironmentSchema);
56
52
 
57
53
  export default Environment;
@@ -34,5 +34,5 @@ const FaqSchema = new Schema<IFaqs>({
34
34
  },
35
35
  });
36
36
 
37
- const Faq = model<IFaqs>("faq", FaqSchema);
37
+ const Faq = mongoose.models.faq || model<IFaqs>("faq", FaqSchema);
38
38
  export default Faq;
@@ -42,6 +42,6 @@ const FeedbackSchema = new Schema<IFeedback>({
42
42
  },
43
43
  });
44
44
 
45
- const Feedback = model<IFeedback>("feedback", FeedbackSchema);
45
+ const Feedback = mongoose.models.feedback || model<IFeedback>("feedback", FeedbackSchema);
46
46
 
47
47
  export default Feedback;
@@ -39,12 +39,10 @@ const GoalSchema = new Schema<IGoal>({
39
39
  type: mongoose.Schema.Types.ObjectId,
40
40
  ref: "organization",
41
41
  default: null,
42
- index: true,
43
42
  },
44
43
  client: {
45
44
  type: mongoose.Schema.Types.ObjectId,
46
45
  ref: "client",
47
- index: true,
48
46
  },
49
47
  type: {
50
48
  type: String,
@@ -72,7 +70,6 @@ const GoalSchema = new Schema<IGoal>({
72
70
  isActive: {
73
71
  type: Boolean,
74
72
  default: true,
75
- index: true,
76
73
  }
77
74
  }, {
78
75
  timestamps: true
@@ -84,6 +81,6 @@ GoalSchema.index({ client: 1, isActive: 1 });
84
81
  GoalSchema.index({ organizationId: 1, client: 1 });
85
82
  GoalSchema.index({ client: 1, name: 1 }, { unique: true });
86
83
 
87
- const Goal = model<IGoal>("goal", GoalSchema);
84
+ const Goal = mongoose.models.goal || model<IGoal>("goal", GoalSchema);
88
85
 
89
86
  export default Goal;
@@ -22,13 +22,11 @@ const HypothesisSchema = new Schema<IHypothesis>({
22
22
  hypothesisNumber: {
23
23
  type: String,
24
24
  trim: true,
25
- index: true,
26
25
  },
27
26
  name: {
28
27
  type: String,
29
28
  required: true,
30
29
  trim: true,
31
- index: true,
32
30
  },
33
31
  action: {
34
32
  type: String,
@@ -49,12 +47,10 @@ const HypothesisSchema = new Schema<IHypothesis>({
49
47
  type: String,
50
48
  default: "General Purpose",
51
49
  trim: true,
52
- index: true,
53
50
  },
54
51
  isActive: {
55
52
  type: Boolean,
56
53
  default: true,
57
- index: true,
58
54
  }
59
55
  }, {
60
56
  timestamps: true
@@ -66,6 +62,6 @@ HypothesisSchema.index({ tagged: 1, isActive: 1 });
66
62
  HypothesisSchema.index({ name: 1, isActive: 1 });
67
63
 
68
64
 
69
- const Hypothesis = model<IHypothesis>("hypos", HypothesisSchema);
65
+ const Hypothesis = mongoose.models.hypothesis || model<IHypothesis>("hypothesis", HypothesisSchema);
70
66
 
71
67
  export default Hypothesis;
@@ -107,7 +107,7 @@ const HypothesisSheetSchema = new Schema<IHypothesisSheet>(
107
107
  }
108
108
  );
109
109
 
110
- const HypothesisSheet = model<IHypothesisSheet>(
110
+ const HypothesisSheet = mongoose.models.hypothesissheet || model<IHypothesisSheet>(
111
111
  "hypothesisSheet",
112
112
  HypothesisSheetSchema
113
113
  );
@@ -10,7 +10,6 @@ const LandingPageDataSchema = new Schema<ILandingPagesData>({
10
10
  type: Number,
11
11
  min: 0,
12
12
  max: 100,
13
- index: true,
14
13
  },
15
14
  lastUpdated: {
16
15
  type: Date,
@@ -33,18 +32,15 @@ const LandingPagesSchema = new Schema<ILandingPages>(
33
32
  type: String,
34
33
  required: true,
35
34
  trim: true,
36
- index: true,
37
35
  },
38
36
  client: {
39
37
  type: mongoose.Schema.Types.ObjectId,
40
38
  ref: "client",
41
39
  required: true,
42
- index: true,
43
40
  },
44
41
  organizationId: {
45
42
  type: mongoose.Schema.Types.ObjectId,
46
43
  ref: "organization",
47
- index: true,
48
44
  },
49
45
  screenshot: {
50
46
  type: String,
@@ -58,7 +54,6 @@ const LandingPagesSchema = new Schema<ILandingPages>(
58
54
  isActive: {
59
55
  type: Boolean,
60
56
  default: true,
61
- index: true,
62
57
  }
63
58
  },
64
59
  {
@@ -76,5 +71,5 @@ LandingPagesSchema.index({ client: 1, 'dataPoints.conversionRate': -1 });
76
71
  // Text index for full-text search
77
72
  LandingPagesSchema.index({ title: 'text' });
78
73
 
79
- const LandingPages = model<ILandingPages>("LandingPages", LandingPagesSchema);
74
+ const LandingPages = mongoose.models.landingpages || model<ILandingPages>("landingpages", LandingPagesSchema);
80
75
  export default LandingPages;
@@ -60,5 +60,5 @@ NewIdeasSchema.index({
60
60
  viewId: 1,
61
61
  });
62
62
 
63
- const NewIdeas = model<INewIdeas>("Newideas", NewIdeasSchema);
63
+ const NewIdeas = mongoose.models.newideas || model<INewIdeas>("newideas", NewIdeasSchema);
64
64
  export default NewIdeas;
@@ -48,6 +48,6 @@ const NotificationSchema = new Schema<INotification>(
48
48
  }
49
49
  );
50
50
 
51
- const Notification = model<INotification>("notification", NotificationSchema);
51
+ const Notification = mongoose.models.notification || model<INotification>("notification", NotificationSchema);
52
52
 
53
53
  export default Notification;
@@ -79,7 +79,7 @@ const OrganizationSchema = new Schema<IOrganization>({
79
79
  }, {
80
80
  timestamps: true
81
81
  });
82
- const Organization = model<IOrganization>("organization", OrganizationSchema);
82
+ const Organization = mongoose.models.organization || model<IOrganization>("organization", OrganizationSchema);
83
83
 
84
84
  OrganizationSchema.index({ name: 1, isActive: 1 });
85
85
 
@@ -45,25 +45,23 @@ const PageSchema = new Schema<IPage>({
45
45
  type: String,
46
46
  required: true,
47
47
  trim: true,
48
- index: true,
48
+
49
49
  },
50
50
  trigger: {
51
51
  type: String,
52
52
  default: "direct",
53
53
  trim: true,
54
- index: true,
54
+
55
55
  },
56
56
  organizationId: {
57
57
  type: mongoose.Schema.Types.ObjectId,
58
58
  ref: "organization",
59
59
  default: null,
60
- index: true,
60
+
61
61
  },
62
62
  client: {
63
63
  type: mongoose.Schema.Types.ObjectId,
64
64
  ref: "client",
65
- required: true,
66
- index: true,
67
65
  },
68
66
  trigger_js: {
69
67
  type: String,
@@ -80,7 +78,6 @@ const PageSchema = new Schema<IPage>({
80
78
  poll_on_rules: {
81
79
  type: Boolean,
82
80
  default: false,
83
- index: true,
84
81
  },
85
82
  deactivation_mode: {
86
83
  type: String,
@@ -96,7 +93,6 @@ const PageSchema = new Schema<IPage>({
96
93
  isActive: {
97
94
  type: Boolean,
98
95
  default: true,
99
- index: true,
100
96
  }
101
97
  }, {
102
98
  timestamps: true
@@ -121,6 +117,6 @@ PageSchema.index({ organizationId: 1, name: 1 });
121
117
  // }
122
118
  // });
123
119
 
124
- const Page = model<IPage>("page", PageSchema);
120
+ const Page = mongoose.models.page || model<IPage>("page", PageSchema);
125
121
 
126
122
  export default Page;
@@ -17,7 +17,6 @@ const PageElementSchema = new Schema<IPageElement>({
17
17
  type: String,
18
18
  required: true,
19
19
  trim: true,
20
- index: true,
21
20
  },
22
21
  slug: {
23
22
  type: String,
@@ -35,13 +34,10 @@ const PageElementSchema = new Schema<IPageElement>({
35
34
  client: {
36
35
  type: mongoose.Schema.Types.ObjectId,
37
36
  ref: "client",
38
- required: true,
39
- index: true,
40
37
  },
41
38
  isActive: {
42
39
  type: Boolean,
43
40
  default: true,
44
- index: true,
45
41
  }
46
42
  }, {
47
43
  timestamps: true
@@ -56,6 +52,6 @@ PageElementSchema.index({ organizationId: 1, name: 1 });
56
52
  // Text index for full-text search
57
53
  PageElementSchema.index({ name: 'text' });
58
54
 
59
- const PageElement = model<IPageElement>("pageelement", PageElementSchema);
55
+ const PageElement = mongoose.models.pageelement || model<IPageElement>("pageelement", PageElementSchema);
60
56
 
61
57
  export default PageElement;
@@ -44,6 +44,6 @@ const PageTestTypeSchema = new Schema<IPageTestType>({
44
44
  PageTestTypeSchema.index({ name: 1, isActive: 1 });
45
45
 
46
46
 
47
- const PageTestType = model<IPageTestType>("pagetesttype", PageTestTypeSchema);
47
+ const PageTestType = mongoose.models.pagetesttype || model<IPageTestType>("pagetesttype", PageTestTypeSchema);
48
48
 
49
49
  export default PageTestType;
@@ -27,6 +27,6 @@ const PortfolioSchema = new Schema<IPortfolio>(
27
27
  }
28
28
  );
29
29
 
30
- const Portfolio = model<IPortfolio>("portfolio", PortfolioSchema);
30
+ const Portfolio = mongoose.models.portfolio || model<IPortfolio>("portfolio", PortfolioSchema);
31
31
 
32
32
  export default Portfolio;
@@ -62,6 +62,7 @@ const PrecalculationFiltersSchema = new Schema<IPrecalculationFilters>({
62
62
  PrecalculationFiltersSchema.index({ organizationId: 1, test: 1 });
63
63
  PrecalculationFiltersSchema.index({ organizationId: 1, client: 1 });
64
64
 
65
- const PrecalculationFilters = model<IPrecalculationFilters>("precalculationfilters", PrecalculationFiltersSchema);
65
+ // Check if model is already registered
66
+ const PrecalculationFilters = mongoose.models.precalculationfilter || model<IPrecalculationFilters>("precalculationfilter", PrecalculationFiltersSchema);
66
67
 
67
68
  export default PrecalculationFilters;
@@ -30,6 +30,6 @@ const QueryLogSchema = new Schema<IQueryLog>(
30
30
  }
31
31
  );
32
32
 
33
- const QueryLog = model<IQueryLog>("querylog", QueryLogSchema);
33
+ const QueryLog = mongoose.models.querylog || model<IQueryLog>("querylog", QueryLogSchema);
34
34
 
35
35
  export default QueryLog;
@@ -32,7 +32,7 @@ const ReadNotificationSchema = new Schema<IReadNotification>(
32
32
  }
33
33
  );
34
34
 
35
- const ReadNotification = model<IReadNotification>(
35
+ const ReadNotification = mongoose.models.readnotification || model<IReadNotification>(
36
36
  "readnotification",
37
37
  ReadNotificationSchema
38
38
  );
@@ -75,6 +75,6 @@ ReportsSchema.index({ client: 1, gaTestId: 1 }); // For GA test ID lookups
75
75
  ReportsSchema.index({ createdBy: 1, to: -1 }); // For user's reports
76
76
  ReportsSchema.index({ client: 1, excludedFromCalculations: 1 }); // For calculation exclusions
77
77
 
78
- const Report = model<IReports>("report", ReportsSchema);
78
+ const Report = mongoose.models.report || model<IReports>("report", ReportsSchema);
79
79
 
80
80
  export default Report;
@@ -48,6 +48,6 @@ RoleSchema.index({
48
48
  description: 'text'
49
49
  });
50
50
 
51
- const Role = model<IRole>("role", RoleSchema);
51
+ const Role = mongoose.models.role || model<IRole>("role", RoleSchema);
52
52
 
53
53
  export default Role;
@@ -32,6 +32,6 @@ const SavedSegmentSchema = new Schema<ISavedSegment>(
32
32
  }
33
33
  );
34
34
 
35
- const SavedSegment = model<ISavedSegment>("savedsegment", SavedSegmentSchema);
35
+ const SavedSegment = mongoose.models.savedsegment || model<ISavedSegment>("savedsegment", SavedSegmentSchema);
36
36
 
37
37
  export default SavedSegment;
@@ -45,6 +45,6 @@ const SegmentSchema = new Schema<ISegment>(
45
45
  }
46
46
  );
47
47
 
48
- const Segment = model<ISegment>("segment", SegmentSchema);
48
+ const Segment = mongoose.models.segment || model<ISegment>("segment", SegmentSchema);
49
49
 
50
50
  export default Segment;
@@ -60,7 +60,7 @@ const SegmentSchema = new Schema<ISegmentCombination>({
60
60
  },
61
61
  });
62
62
 
63
- const SegmentCombination = model<ISegmentCombination>(
63
+ const SegmentCombination = mongoose.models.segmentcombination || model<ISegmentCombination>(
64
64
  "segmentcombination",
65
65
  SegmentSchema
66
66
  );
@@ -41,7 +41,6 @@ const SnippetSchema = new Schema<ISnippet>(
41
41
  type: mongoose.Schema.Types.ObjectId,
42
42
  ref: "client",
43
43
  required: true,
44
- index: true,
45
44
  },
46
45
  details: {
47
46
  type: String,
@@ -56,7 +55,6 @@ const SnippetSchema = new Schema<ISnippet>(
56
55
  type: [mongoose.Schema.Types.ObjectId],
57
56
  ref: "tag",
58
57
  default: [],
59
- index: true,
60
58
  },
61
59
  htmlcode: {
62
60
  type: String,
@@ -81,12 +79,10 @@ const SnippetSchema = new Schema<ISnippet>(
81
79
  type: String,
82
80
  default: "live",
83
81
  enum: ["live", "draft","running","paused","preview","ended"],
84
- index: true,
85
82
  },
86
83
  isActive: {
87
84
  type: Boolean,
88
85
  default: true,
89
- index: true,
90
86
  }
91
87
  },
92
88
  {
@@ -101,6 +97,6 @@ SnippetSchema.index({ client: 1, tags: 1 });
101
97
  SnippetSchema.index({ client: 1, pageelement: 1 });
102
98
 
103
99
 
104
- const Snippet = model<ISnippet>("snippet", SnippetSchema);
100
+ const Snippet = mongoose.models.snippet || model<ISnippet>("snippet", SnippetSchema);
105
101
 
106
102
  export default Snippet;
@@ -55,7 +55,7 @@ const StageInCustomerJourneySchema = new Schema<IStageInCustomerJourney>(
55
55
 
56
56
  // Compound indexes for common query patterns
57
57
  // StageInCustomerJourneySchema.index({ client: 1, slug: 1 });
58
- const StageInCustomerJourney = model<IStageInCustomerJourney>(
58
+ const StageInCustomerJourney = mongoose.models.stageincustomerjourney || model<IStageInCustomerJourney>(
59
59
  "stageincustomerjourney",
60
60
  StageInCustomerJourneySchema
61
61
  );
package/src/models/Tag.ts CHANGED
@@ -28,6 +28,6 @@ const TagSchema = new Schema<ITag>({
28
28
  },
29
29
  });
30
30
 
31
- const Tag = model<ITag>("tag", TagSchema);
31
+ const Tag = mongoose.models.tag || model<ITag>("tag", TagSchema);
32
32
 
33
33
  export default Tag;
@@ -31,6 +31,6 @@ const TempSchema = new Schema<ITemp>({
31
31
  },
32
32
  });
33
33
 
34
- const Temp = model<ITemp>("temp", TempSchema);
34
+ const Temp = mongoose.models.temp || model<ITemp>("temp", TempSchema);
35
35
 
36
36
  export default Temp;
@@ -219,6 +219,6 @@ TestSchema.index({ client: 1, status: 1 }, { partialFilterExpression: { status:
219
219
  // Add TTL index for automatic cleanup of ended tests after 1 year
220
220
  TestSchema.index({ enddate: 1 }, { expireAfterSeconds: 31536000 });
221
221
 
222
- const Test = model<ITest>("test", TestSchema);
222
+ const Test = mongoose.models.test || model<ITest>("test", TestSchema);
223
223
 
224
224
  export default Test;
@@ -47,7 +47,7 @@ const TestSequentialValueSchema = new Schema<ITestSequentialValue>(
47
47
 
48
48
  TestSequentialValueSchema.index({ test: 1 });
49
49
 
50
- const TestSequentialValue = model<ITestSequentialValue>(
50
+ const TestSequentialValue = mongoose.models.testsequentialvalue || model<ITestSequentialValue>(
51
51
  "testsequentialvalue",
52
52
  TestSequentialValueSchema
53
53
  );
@@ -37,6 +37,6 @@ const TierSchema = new Schema<ITier>({
37
37
  },
38
38
  });
39
39
 
40
- const Tier = model<ITier>("tier", TierSchema);
40
+ const Tier = mongoose.models.tier || model<ITier>("tier", TierSchema);
41
41
 
42
42
  export default Tier;
@@ -34,5 +34,5 @@ const TriggerSchema = new Schema<ITrigger>({
34
34
  },
35
35
  });
36
36
 
37
- const Trigger = model<ITrigger>("trigger", TriggerSchema);
37
+ const Trigger = mongoose.models.trigger || model<ITrigger>("trigger", TriggerSchema);
38
38
  export default Trigger;
@@ -58,5 +58,5 @@ UserSchema.index({ organizationId: 1, role: 1 });
58
58
  UserSchema.index({ organizationId: 1, client: 1 });
59
59
  UserSchema.index({ email: 1 }, { unique: true });
60
60
 
61
- const User = model<IUser>("user", UserSchema);
61
+ const User = mongoose.models.user || model<IUser>("user", UserSchema);
62
62
  export default User;