shuttlepro-shared 1.3.39 → 1.3.40

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 (73) hide show
  1. package/common/repositories/customerProfile.repository.js +14 -83
  2. package/common/repositories/userRole.repository.js +2 -5
  3. package/config/redis.js +73 -72
  4. package/middlewares/checkPermission/index.js +23 -36
  5. package/models/ActivityLogs.js +0 -1
  6. package/models/AgentActivity.js +4 -5
  7. package/models/Card.js +1 -50
  8. package/models/Chatbot.js +1 -1
  9. package/models/Column.js +0 -6
  10. package/models/Conversation.js +0 -40
  11. package/models/Customer.js +1 -2
  12. package/models/Integration.js +0 -6
  13. package/models/Order.js +0 -11
  14. package/models/Profile.js +1 -3
  15. package/models/Workspace.js +4 -78
  16. package/models.js +49 -168
  17. package/package.json +1 -1
  18. package/models/Activity.js +0 -28
  19. package/models/Attribute.js +0 -130
  20. package/models/Automation.js +0 -242
  21. package/models/BusinessRule.js +0 -16
  22. package/models/BusinessRuleHelper.js +0 -13
  23. package/models/Catalogue.js +0 -22
  24. package/models/Category.js +0 -129
  25. package/models/ChatMemberSession.js +0 -21
  26. package/models/ChatMessage.js +0 -43
  27. package/models/Color.js +0 -10
  28. package/models/CustomerCheckpoint.js +0 -21
  29. package/models/DeviceInfo.js +0 -13
  30. package/models/Email.js +0 -21
  31. package/models/EmailMessage.js +0 -30
  32. package/models/EmailNotification.js +0 -17
  33. package/models/EscalationConfiguration.js +0 -123
  34. package/models/EscalationManager.js +0 -50
  35. package/models/Faq.js +0 -29
  36. package/models/FeedbackResponse.js +0 -72
  37. package/models/FormTemplate.js +0 -27
  38. package/models/InternalComments.js +0 -27
  39. package/models/InternalThreads.js +0 -20
  40. package/models/JobDesign.js +0 -32
  41. package/models/JobQueue.js +0 -17
  42. package/models/LabelsPdf.js +0 -12
  43. package/models/Layout.js +0 -12
  44. package/models/LoadSheet.js +0 -31
  45. package/models/Location.js +0 -147
  46. package/models/Logo.js +0 -11
  47. package/models/MailGroup.js +0 -21
  48. package/models/Notification.js +0 -32
  49. package/models/OrderPdf.js +0 -29
  50. package/models/PostsAutomation.js +0 -66
  51. package/models/Product.js +0 -336
  52. package/models/ProductAttachment.js +0 -158
  53. package/models/ProductAttribute.js +0 -140
  54. package/models/ProductCategory.js +0 -128
  55. package/models/ProductLabels.js +0 -11
  56. package/models/ProductShopify.js +0 -13
  57. package/models/ProductTag.js +0 -124
  58. package/models/ProductVariant.js +0 -156
  59. package/models/ServiceUsage.js +0 -26
  60. package/models/ShipperSetting.js +0 -24
  61. package/models/SocialGroup.js +0 -127
  62. package/models/SocialPost.js +0 -40
  63. package/models/SocialProfile.js +0 -56
  64. package/models/Story.js +0 -86
  65. package/models/Tag.js +0 -77
  66. package/models/Template.js +0 -76
  67. package/models/TemplateFrame.js +0 -55
  68. package/models/TemplateTag.js +0 -10
  69. package/models/UserGuide.js +0 -21
  70. package/models/UserSession.js +0 -47
  71. package/models/VariantLocation.js +0 -145
  72. package/models/WhatsappFlow.js +0 -29
  73. package/models/Workflow.js +0 -34
@@ -6,18 +6,17 @@ const CustomerSchema = new Schema(
6
6
  name: { type: String, default: "" },
7
7
  email: { type: String, default: "" },
8
8
  phone: { type: String, default: "" },
9
- phone1: { type: String, default: "" },
10
9
  city: { type: String, default: "" },
11
10
  country: { type: String, default: "pk" },
12
11
  defaultAddress: { type: String, default: "" },
13
12
  currentShippingAddress: {},
14
13
  addresses: [],
15
- webCustomerId: { type: String, default: "" },
16
14
  workspaceId: {
17
15
  type: Schema.Types.ObjectId,
18
16
  ref: "Workspace",
19
17
  default: null,
20
18
  },
19
+ phone1: { type: String, default: "" },
21
20
  isBlackListed: { type: Boolean, default: false },
22
21
  createdBy: {
23
22
  type: Schema.Types.ObjectId,
@@ -48,10 +48,4 @@ const IntegrationSchema = new mongoose.Schema(
48
48
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
49
49
  );
50
50
 
51
- IntegrationSchema.virtual("conversations", {
52
- ref: "Conversation",
53
- localField: "_id",
54
- foreignField: "platformId",
55
- });
56
-
57
51
  module.exports = mongoose.model("Integration", IntegrationSchema);
package/models/Order.js CHANGED
@@ -136,14 +136,6 @@ const OrderSchema = new Schema(
136
136
  paymentDate: { type: String, default: "" },
137
137
  paymentDetails: {},
138
138
  },
139
- merged: {
140
- status: { type: String, default: "open" },
141
- webOrderNumbers: [],
142
- orderNumbers: [],
143
- localOrderIds: [],
144
- webOrderIds: [],
145
- details: [],
146
- },
147
139
  credentials: {},
148
140
  ticketId: { type: String, default: "" },
149
141
  sender: { type: String, default: "" },
@@ -167,9 +159,6 @@ const OrderSchema = new Schema(
167
159
  },
168
160
  orderName: { type: String, default: "" },
169
161
  totalWeight: { type: String, default: "" },
170
- currency: {},
171
- presentedCurrency: {},
172
- exchangeRate: { type: Number, default: 0 },
173
162
  },
174
163
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
175
164
  );
package/models/Profile.js CHANGED
@@ -68,9 +68,7 @@ const fetchProfileByEmailAndWorkspaceId = async (
68
68
  try {
69
69
  let profiles = await fetchProfiles(workspaceId);
70
70
  let profile = profiles.find(
71
- (p) =>
72
- p?.userName === userName &&
73
- p?.workspaceId?.toString() === workspaceId?.toString()
71
+ (p) => p?.userName === userName && p?.workspaceId === workspaceId
74
72
  );
75
73
  return profile || null;
76
74
  } catch (err) {
@@ -1,24 +1,7 @@
1
1
  const mongoose = require("mongoose");
2
- const SettingModel = require("./Setting");
3
- const SocialMediaSettingModel = require("./SocialMediaSetting");
4
- const { Schema } = mongoose;
5
-
6
- const generateSlug = (input) => {
7
- return input
8
- .trim()
9
- .toLowerCase()
10
- .replace(/[^a-z0-9\s-]/g, "")
11
- .replace(/\s+/g, "-")
12
- .replace(/-+/g, "-");
13
- };
14
-
15
2
  //TODO: task manager and default location creation
16
3
  const shiftSchema = new mongoose.Schema(
17
4
  {
18
- _id: {
19
- type: mongoose.Schema.Types.ObjectId,
20
- default: () => new mongoose.Types.ObjectId(),
21
- },
22
5
  shiftName: {
23
6
  type: String,
24
7
  required: true,
@@ -178,13 +161,6 @@ const workspaceSchema = new mongoose.Schema(
178
161
  required: true,
179
162
  trim: true,
180
163
  },
181
- slug: {
182
- type: String,
183
- required: true,
184
- trim: true,
185
- default: "",
186
- unique: true,
187
- },
188
164
  iconUrl: { type: String, default: "" },
189
165
  thumbUrl: { type: String, default: "" },
190
166
  createdBy: {
@@ -297,9 +273,6 @@ const workspaceSchema = new mongoose.Schema(
297
273
  "url",
298
274
  "colour",
299
275
  "file",
300
- "starRating",
301
- "paragraph",
302
- "heading",
303
276
  ],
304
277
  },
305
278
  option: {
@@ -319,44 +292,9 @@ const workspaceSchema = new mongoose.Schema(
319
292
  default: "everyone",
320
293
  },
321
294
  defaultShift: { type: String, default: "" },
322
- automationManager: {
323
- delayThreshold: {
324
- type: Number,
325
- default: 5,
326
- },
327
- messageCount: {
328
- type: Number,
329
- default: 3,
330
- },
331
- },
332
295
  },
333
296
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
334
297
  );
335
-
336
- workspaceSchema.virtual("products", {
337
- ref: "Product",
338
- localField: "_id",
339
- foreignField: "workspaceId",
340
- });
341
-
342
- workspaceSchema.virtual("orders", {
343
- ref: "Order",
344
- localField: "_id",
345
- foreignField: "workspaceId",
346
- });
347
-
348
- workspaceSchema.virtual("socialProfilesArr", {
349
- ref: "socialProfile",
350
- localField: "_id",
351
- foreignField: "workspaceId",
352
- });
353
-
354
- workspaceSchema.virtual("integrations", {
355
- ref: "Integration",
356
- localField: "_id",
357
- foreignField: "workspaceId",
358
- });
359
-
360
298
  const commonOptions = {
361
299
  type: String,
362
300
  trim: true,
@@ -373,22 +311,10 @@ workspaceSchema.add({
373
311
  chatGptApiKey: commonOptions,
374
312
  });
375
313
 
376
- workspaceSchema.pre("save", async function (next) {
377
- if (this.isModified("name")) {
378
- let slug = generateSlug(this.name);
379
- let slugExists = await mongoose.models.Workspace.findOne({ slug });
380
-
381
- let counter = 1;
382
- while (slugExists) {
383
- slug = `${slug}-${counter}`;
384
- slugExists = await mongoose.models.Workspace.findOne({ slug });
385
- counter++;
386
- }
387
-
388
- this.slug = slug;
389
- }
390
- next();
314
+ workspaceSchema.virtual("integrations", {
315
+ ref: "Integration",
316
+ localField: "_id",
317
+ foreignField: "workspaceId",
391
318
  });
392
-
393
319
  const Workspace = mongoose.model("Workspace", workspaceSchema);
394
320
  module.exports = Workspace;
package/models.js CHANGED
@@ -1,213 +1,94 @@
1
- const Activity = require("./models/Activity");
2
- const ActivityLogs = require("./models/ActivityLogs");
3
- const AgentActivity = require("./models/AgentActivity");
1
+ const Website = require("./models/Website");
2
+ const ChatMember = require("./models/ChatMember");
3
+ const DescriptionTemplate = require("./models/DescriptionTemplate");
4
+ const ProductQueue = require("./models/ProductQueue");
5
+ const ColumnPreference = require("./models/ColumnPreference");
6
+ const UserPermission = require("./models/UserPermission");
7
+ const GoogleClientInfo = require("./models/GoogleClientInfo");
8
+ const GoogleCredentials = require("./models/GoogleCredentials");
9
+ const User = require("./models/User");
4
10
  const AllPostSchema = require("./models/AllPost");
5
11
  const AllPostBatchSchema = require("./models/AllPostBatch");
6
12
  const AllPostScheduleSchema = require("./models/AllPostSchedule");
7
- const Assignment = require("./models/Assignment");
8
- const Attribute = require("./models/Attribute");
9
- const Automation = require("./models/Automation");
10
13
  const AutoSchedulerSchema = require("./models/AutoScheduler");
14
+ const ActivityLogs = require("./models/ActivityLogs");
15
+ const UserRole = require("./models/UserRole");
16
+ const OrderQueue = require("./models/OrderQueue");
17
+ const AgentActivity = require("./models/AgentActivity");
18
+ const Assignment = require("./models/Assignment");
11
19
  const BusinessDistribution = require("./models/BusinessDistribution");
12
- const BusinessRule = require("./models/BusinessRule");
13
- const BusinessRuleHelper = require("./models/BusinessRuleHelper");
14
- const Card = require("./models/Card");
15
20
  const CardComments = require("./models/CardComments");
16
- const Catalogue = require("./models/Catalogue");
17
- const Category = require("./models/Category");
18
- const Chatbot = require("./models/Chatbot");
19
- const ChatMember = require("./models/ChatMember");
20
- const ChatMemberSession = require("./models/ChatMemberSession");
21
- const ChatMessage = require("./models/ChatMessage");
22
21
  const Checkpoint = require("./models/Checkpoint");
23
22
  const City = require("./models/City");
24
- const Color = require("./models/Color");
25
23
  const Column = require("./models/Column");
26
- const ColumnPreference = require("./models/ColumnPreference");
27
24
  const Conversation = require("./models/Conversation");
28
25
  const Customer = require("./models/Customer");
29
- const CustomerCheckpoint = require("./models/CustomerCheckpoint");
30
- const CustomerProfile = require("./models/CustomerProfile");
31
- const CustomerTimeline = require("./models/CustomerTimeline");
32
- const DefaultRolePermission = require("./models/DefaultRolePermission");
33
- const DescriptionTemplate = require("./models/DescriptionTemplate");
34
- const DeviceInfo = require("./models/DeviceInfo");
35
- const Email = require("./models/Email");
36
- const EmailMessage = require("./models/EmailMessage");
37
- const EmailNotification = require("./models/EmailNotification");
38
- const EscalationConfiguration = require("./models/EscalationConfiguration");
39
- const EscalationManager = require("./models/EscalationManager");
40
- const Faq = require("./models/Faq");
41
- const FeedbackResponse = require("./models/FeedbackResponse");
42
- const FormTemplate = require("./models/FormTemplate");
43
- const GoogleClientInfo = require("./models/GoogleClientInfo");
44
- const GoogleCredentials = require("./models/GoogleCredentials");
45
26
  const Integration = require("./models/Integration");
46
- const InternalComments = require("./models/InternalComments");
47
- const InternalThreads = require("./models/InternalThreads");
48
- const JobDesign = require("./models/JobDesign");
49
- const JobQueue = require("./models/JobQueue");
50
27
  const Label = require("./models/Label");
51
- const LabelPdf = require("./models/LabelsPdf");
52
- const Layout = require("./models/Layout");
53
- const LoadSheet = require("./models/LoadSheet");
54
- const Location = require("./models/Location");
55
- const Logo = require("./models/Logo");
56
- const MailGroup = require("./models/MailGroup");
57
28
  const Message = require("./models/Message");
58
- const NewProduct = require("./models/NewProduct");
59
- const Notification = require("./models/Notification");
60
- const NotificationSettings = require("./models/NotificationSettings");
61
29
  const Order = require("./models/Order");
62
- const OrderPdf = require("./models/OrderPdf");
63
30
  const OrderProduct = require("./models/OrderProduct");
64
- const OrderQueue = require("./models/OrderQueue");
65
- const PostsAutomation = require("./models/PostsAutomation");
66
- const Product = require("./models/Product");
67
- const ProductAttachment = require("./models/ProductAttachment");
68
- const ProductAttribute = require("./models/ProductAttribute");
69
- const ProductCategory = require("./models/ProductCategory");
70
- const ProductLabel = require("./models/ProductLabels");
71
- const ProductQueue = require("./models/ProductQueue");
72
- const ProductShopify = require("./models/ProductShopify");
73
- const ProductTag = require("./models/ProductTag");
74
- const ProductVariant = require("./models/ProductVariant");
75
- const Profile = require("./models/Profile");
76
31
  const Report = require("./models/Report");
77
- const Role = require("./models/Role");
78
- const Setting = require("./models/Setting");
79
- const ServiceUsage = require("./models/ServiceUsage");
80
32
  const Shipper = require("./models/Shipper");
81
- const ShipperSetting = require("./models/ShipperSetting");
82
- const SocialGroup = require("./models/SocialGroup");
83
- const SocialMediaSetting = require("./models/SocialMediaSetting");
84
- const SocialPost = require("./models/SocialPost");
85
- const SocialProfile = require("./models/SocialProfile");
86
33
  const Status = require("./models/Status");
87
34
  const StatusType = require("./models/StatusType");
88
- const Step = require("./models/Step");
89
- const Story = require("./models/Story");
90
- const Tag = require("./models/Tag");
91
- const Template = require("./models/Template");
92
- const TemplateFrame = require("./models/TemplateFrame");
93
- const TemplateTag = require("./models/TemplateTag");
94
35
  const Type = require("./models/Type");
95
- const User = require("./models/User");
96
- const UserGuide = require("./models/UserGuide");
97
- const UserPermission = require("./models/UserPermission");
98
- const UserRole = require("./models/UserRole");
99
- const UserSession = require("./models/UserSession");
100
- const UserWorkflow = require("./models/UserWorkflow");
101
- const VariantLocation = require("./models/VariantLocation");
102
- const Website = require("./models/Website");
103
- const WhatsappFlow = require("./models/WhatsappFlow");
104
- const Workflow = require("./models/Workflow");
105
36
  const Workspace = require("./models/Workspace");
106
-
37
+ const Card = require("./models/Card");
38
+ const Profile = require("./models/Profile");
39
+ const Chatbot = require("./models/Chatbot");
40
+ const Step = require("./models/Step");
41
+ const Role = require("./models/Role");
42
+ const NewProduct = require("./models/NewProduct");
43
+ const NotificationSettings = require("./models/NotificationSettings");
44
+ const UserWorkflow = require("./models/UserWorkflow");
45
+ const Setting = require("./models/Setting");
46
+ const CustomerProfile = require("./models/CustomerProfile");
107
47
  module.exports = {
108
- Activity,
109
- ActivityLogs,
110
- AgentActivity,
48
+ Website,
49
+ ProductQueue,
50
+ ColumnPreference,
51
+ UserPermission,
52
+ User,
53
+ GoogleClientInfo,
54
+ GoogleCredentials,
111
55
  AllPostSchema,
112
56
  AllPostBatchSchema,
113
57
  AllPostScheduleSchema,
114
- Assignment,
115
- Attribute,
116
- Automation,
117
58
  AutoSchedulerSchema,
59
+ ActivityLogs,
60
+ UserRole,
61
+ OrderQueue,
62
+ AgentActivity,
63
+ Assignment,
118
64
  BusinessDistribution,
119
- BusinessRule,
120
- BusinessRuleHelper,
121
- Card,
122
65
  CardComments,
123
- Catalogue,
124
- Category,
125
- Chatbot,
126
- ChatMember,
127
- ChatMemberSession,
128
- ChatMessage,
129
66
  Checkpoint,
130
- City,
131
- Color,
132
67
  Column,
133
- ColumnPreference,
134
68
  Conversation,
69
+ City,
135
70
  Customer,
136
- CustomerCheckpoint,
137
- CustomerProfile,
138
- CustomerTimeline,
139
- DefaultRolePermission,
140
- DescriptionTemplate,
141
- DeviceInfo,
142
- Email,
143
- EmailMessage,
144
- EmailNotification,
145
- EscalationConfiguration,
146
- EscalationManager,
147
- Faq,
148
- FeedbackResponse,
149
- FormTemplate,
150
- GoogleClientInfo,
151
- GoogleCredentials,
152
71
  Integration,
153
- InternalComments,
154
- InternalThreads,
155
- JobDesign,
156
- JobQueue,
157
72
  Label,
158
- LabelPdf,
159
- LoadSheet,
160
- Layout,
161
- Location,
162
- Logo,
163
- MailGroup,
164
73
  Message,
165
- NewProduct,
166
- Notification,
167
- NotificationSettings,
168
74
  Order,
169
- OrderPdf,
170
75
  OrderProduct,
171
- OrderQueue,
172
- PostsAutomation,
173
- Product,
174
- ProductAttachment,
175
- ProductAttribute,
176
- ProductCategory,
177
- ProductLabel,
178
- ProductQueue,
179
- ProductShopify,
180
- ProductTag,
181
- ProductVariant,
182
- Profile,
183
76
  Report,
184
- Role,
185
- Setting,
186
- ServiceUsage,
187
77
  Shipper,
188
- ShipperSetting,
189
- SocialGroup,
190
- SocialMediaSetting,
191
- SocialPost,
192
- SocialProfile,
193
78
  Status,
79
+ Type,
80
+ Workspace,
194
81
  StatusType,
82
+ Card,
83
+ DescriptionTemplate,
84
+ Profile,
85
+ ChatMember,
86
+ Chatbot,
195
87
  Step,
196
- Story,
197
- Tag,
198
- Template,
199
- TemplateFrame,
200
- TemplateTag,
201
- Type,
202
- User,
203
- UserGuide,
204
- UserPermission,
205
- UserRole,
206
- UserSession,
88
+ Role,
89
+ NewProduct,
90
+ NotificationSettings,
207
91
  UserWorkflow,
208
- VariantLocation,
209
- Website,
210
- WhatsappFlow,
211
- Workflow,
212
- Workspace,
92
+ Setting,
93
+ CustomerProfile,
213
94
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.39",
3
+ "version": "1.3.40",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,28 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
-
4
- const ActivitySchema = new Schema(
5
- {
6
- trackingId: { type: String, default: "" },
7
- date: { type: String, default: "" },
8
- name: { type: String, default: "" },
9
- type: { type: String, default: "" },
10
- orderId: { type: String, default: "" },
11
- emailId: { type: Schema.Types.ObjectId, ref: "Email" },
12
- mailGroupId: { type: Schema.Types.ObjectId, ref: "MailGroup" },
13
- templateId: { type: Schema.Types.ObjectId, ref: "DescriptionTemplate" },
14
- message: { type: String, default: "" },
15
- status: { type: String, default: "" },
16
- customerName: { type: String, default: "" },
17
- contact: { type: String, default: "" },
18
- notificationTimer: { type: String, default: "" },
19
- scheduledTime: { type: String, default: "" },
20
- workspaceId: { type: String, default: "" },
21
- subject: { type: String, default: "" },
22
- userName: { type: String, default: "" },
23
- },
24
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
25
- );
26
-
27
- const Activity = mongoose.model("Activity", ActivitySchema);
28
- module.exports = Activity;
@@ -1,130 +0,0 @@
1
- const mongoose = require("mongoose");
2
- const { Schema } = mongoose;
3
- const AttributeSchema = new Schema(
4
- {
5
- name: { type: String, default: "" },
6
- webAttributeId: { type: Number, default: null },
7
- parentId: { type: Schema.Types.ObjectId, ref: "Attribute", default: null },
8
- workspaceId: {
9
- type: Schema.Types.ObjectId,
10
- ref: "Workspace",
11
- default: null,
12
- },
13
- oldId: { type: String, default: "" },
14
- createdBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
15
- updatedBy: { type: Schema.Types.ObjectId, ref: "User", default: null },
16
- isDeleted: { type: Boolean, default: false },
17
- isDefault: { type: Boolean, default: false },
18
- },
19
- { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
20
- );
21
- AttributeSchema.virtual("values", {
22
- ref: "Attribute",
23
- localField: "_id",
24
- foreignField: "parentId",
25
- });
26
-
27
- const Attribute = mongoose.model("Attribute", AttributeSchema);
28
-
29
- const createNewAttribute = async (attributeData) => {
30
- try {
31
- return await Attribute.create(attributeData);
32
- } catch (error) {
33
- console.log(error);
34
- return null;
35
- }
36
- };
37
-
38
- const attributesInsertMany = async (data) => {
39
- try {
40
- return await Attribute.insertMany(data);
41
- } catch (error) {
42
- return [];
43
- }
44
- };
45
-
46
- const findAttributeById = async (attributeId) => {
47
- try {
48
- return await Attribute.findById(attributeId);
49
- } catch (error) {
50
- console.log(error);
51
- return null;
52
- }
53
- };
54
-
55
- const updateAttributeById = async (criteria, updateData, options = {}) => {
56
- try {
57
- return await Attribute.findByIdAndUpdate(criteria, updateData, options);
58
- } catch (error) {
59
- console.log(error);
60
- return null;
61
- }
62
- };
63
-
64
- const deleteAttributeById = async (attributeId) => {
65
- try {
66
- return await Attribute.findByIdAndDelete(attributeId);
67
- } catch (error) {
68
- console.log(error);
69
- return null;
70
- }
71
- };
72
-
73
- const findAttribute = async (criteria) => {
74
- try {
75
- return await Attribute.findOne(criteria);
76
- } catch (error) {
77
- console.log(error);
78
- return null;
79
- }
80
- };
81
-
82
- const findAttributes = async (criteria) => {
83
- try {
84
- return await Attribute.find(criteria);
85
- } catch (error) {
86
- console.log(error);
87
- return null;
88
- }
89
- };
90
-
91
- const attributesByAggregation = async (pipeline) => {
92
- try {
93
- return await Attribute.aggregate(pipeline);
94
- } catch (error) {
95
- console.log(error);
96
- return null;
97
- }
98
- };
99
-
100
- const attributesUpdateMany = async (criteria, updateData, options = {}) => {
101
- try {
102
- return await Attribute.updateMany(criteria, updateData, options);
103
- } catch (error) {
104
- console.log(error);
105
- return null;
106
- }
107
- };
108
-
109
- const findAttributesWithPopulate = async (criteria, populate) => {
110
- try {
111
- return await Attribute.find(criteria).populate(populate);
112
- } catch (error) {
113
- console.log(error);
114
- return null;
115
- }
116
- };
117
-
118
- module.exports = {
119
- Attribute,
120
- createNewAttribute,
121
- findAttributeById,
122
- updateAttributeById,
123
- deleteAttributeById,
124
- findAttribute,
125
- findAttributes,
126
- attributesByAggregation,
127
- attributesInsertMany,
128
- attributesUpdateMany,
129
- findAttributesWithPopulate,
130
- };