flykup_model_production 1.0.8 → 1.0.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.
@@ -1,4 +1,4 @@
1
- import mongoose, { Schema, model } from 'mongoose';
1
+ import mongoose, { Schema } from "mongoose";
2
2
 
3
3
  const coHostInviteSchema = new Schema(
4
4
  {
@@ -17,40 +17,43 @@ const coHostInviteSchema = new Schema(
17
17
  values: ["sellers", "dropshippers"],
18
18
  message: `{VALUE} is invalid host model`,
19
19
  },
20
- }
21
- },
22
- cohost: {
23
- userId: { type: Schema.Types.ObjectId, ref: "users", required: true },
24
- hostId: {
25
- type: mongoose.Schema.Types.ObjectId,
26
- required: true,
27
- refPath: "cohost.hostModel",
28
20
  },
29
- hostModel: {
30
- type: String,
31
- required: true,
32
- enum: {
33
- values: ["sellers", "dropshippers"],
34
- message: `{VALUE} is invalid cohost model`,
35
- },
36
- }
37
- },
38
- status: {
39
- type: String,
40
- enum: ["pending", "accepted", "rejected", "cancelled", "left"],
41
- default: "pending",
42
- index: true
43
21
  },
44
- joinedAt: Date,
45
- leftAt: Date,
46
- liveStreamId: String,
22
+
23
+
24
+ cohosts: [
25
+ {
26
+ userId: { type: Schema.Types.ObjectId, ref: "users", required: true },
27
+ hostId: {
28
+ type: mongoose.Schema.Types.ObjectId,
29
+ required: true,
30
+ refPath: "cohosts.hostModel",
31
+ },
32
+ hostModel: {
33
+ type: String,
34
+ required: true,
35
+ enum: {
36
+ values: ["sellers", "dropshippers"],
37
+ message: `{VALUE} is invalid cohost model`,
38
+ },
39
+ },
40
+ status: {
41
+ type: String,
42
+ enum: ["pending", "accepted", "rejected", "cancelled", "left"],
43
+ default: "pending",
44
+ },
45
+ joinedAt: Date,
46
+ leftAt: Date,
47
+ liveStreamId: String,
48
+ },
49
+ ],
47
50
  },
48
51
  { timestamps: true }
49
52
  );
50
53
 
51
- coHostInviteSchema.index({ show: 1, status: 1 });
52
- coHostInviteSchema.index({ "cohost.userId": 1, status: 1 });
53
-
54
+ // Indexing for faster queries
55
+ coHostInviteSchema.index({ show: 1, "cohosts.status": 1 });
56
+ coHostInviteSchema.index({ "cohosts.userId": 1, "cohosts.status": 1 });
54
57
  // Safe export to prevent OverwriteModelError
55
58
  const CoHostInvite = mongoose.models.cohostinvites || mongoose.model("cohostinvites", coHostInviteSchema);
56
59
 
@@ -293,6 +293,20 @@ const SellerSchema = new mongoose.Schema(
293
293
  },
294
294
  { timestamps: true, strict: true }
295
295
  );
296
-
296
+ // Add text index for seller fields
297
+ SellerSchema.index({
298
+ companyName: "text",
299
+ email: "text",
300
+ mobileNumber: "text",
301
+ productCategories: "text"
302
+ }, {
303
+ weights: {
304
+ companyName: 4,
305
+ email: 2,
306
+ mobileNumber: 1,
307
+ productCategories: 1
308
+ },
309
+ name: "seller_text_index"
310
+ });
297
311
  const Seller = mongoose.models.sellers || mongoose.model("sellers", SellerSchema);
298
312
  export default Seller;
@@ -168,6 +168,19 @@ UserSchema.methods.createJwtToken = function () {
168
168
  { expiresIn: "4d" }
169
169
  );
170
170
  };
171
+ UserSchema.index({
172
+ userName: "text",
173
+ name: "text",
174
+ emailId: "text"
175
+ }, {
176
+ weights: {
177
+ userName: 3,
178
+ name: 3,
179
+ emailId: 2
180
+ },
181
+ name: "user_text_index"
182
+ });
183
+
171
184
 
172
185
  UserSchema.methods.comparePassword = async function (loginPassword) {
173
186
  if (!this.password) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flykup_model_production",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "private": false,