flykup_model_production 1.0.16 → 1.0.17
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/.gitattributes +2 -0
- package/.github/workflows/publish.yml +31 -0
- package/auth.js +14 -14
- package/config.js +1 -1
- package/db_connection.js +23 -23
- package/index.js +140 -140
- package/models/AadhaarVerification.js +131 -131
- package/models/AdminEmail.model.js +38 -38
- package/models/BankVerification.js +92 -92
- package/models/GSTVerification.js +89 -89
- package/models/LiveStreamInteraction.model.js +101 -101
- package/models/ProductInteraction.model.js +108 -108
- package/models/Review.model.js +121 -121
- package/models/SearchAnalytics.js +23 -23
- package/models/ShoppableInteraction.model.js +106 -106
- package/models/Wishlist.model.js +29 -29
- package/models/admin.model.js +42 -42
- package/models/appUpdate.model.js +19 -19
- package/models/assets.model.js +32 -32
- package/models/blockedRegion.models.js +27 -27
- package/models/chat.model.js +511 -511
- package/models/coHostInvitation.model.js +60 -60
- package/models/follow.model.js +38 -38
- package/models/loginlogs.model.js +26 -26
- package/models/notification.model.js +130 -129
- package/models/order.modal.js +385 -385
- package/models/orderPayment.model.js +218 -218
- package/models/productListing.model.js +322 -322
- package/models/profileInteractions.model.js +44 -44
- package/models/registerShow.model.js +29 -29
- package/models/sellerDraft.model.js +27 -27
- package/models/shipper.model.js +126 -126
- package/models/shoppableVideo.model.js +237 -237
- package/models/shoppableVideoComment.model.js +57 -57
- package/models/shoppableVideoLike.model.js +29 -29
- package/models/shoppableVideoSave.model.js +27 -27
- package/models/shows.model.js +603 -603
- package/models/stock.model.js +105 -105
- package/models/ticket.model.js +115 -115
- package/package.json +18 -18
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import mongoose, { Schema, model } from 'mongoose';
|
|
2
|
-
|
|
3
|
-
const AdminEmailSchema = new Schema({
|
|
4
|
-
email: {
|
|
5
|
-
type: String,
|
|
6
|
-
required: true,
|
|
7
|
-
unique: true,
|
|
8
|
-
lowercase: true,
|
|
9
|
-
trim: true
|
|
10
|
-
},
|
|
11
|
-
isActive: {
|
|
12
|
-
type: Boolean,
|
|
13
|
-
default: true
|
|
14
|
-
},
|
|
15
|
-
permissions: {
|
|
16
|
-
shoppableVideo: {
|
|
17
|
-
type: Boolean,
|
|
18
|
-
default: false
|
|
19
|
-
},
|
|
20
|
-
productAccess: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: false
|
|
23
|
-
},
|
|
24
|
-
totalAccess: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: false
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}, {
|
|
30
|
-
timestamps: true
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Index for faster querying
|
|
34
|
-
AdminEmailSchema.index({ email: 1, isActive: 1 });
|
|
35
|
-
|
|
36
|
-
// Export safely
|
|
37
|
-
const AdminEmail = mongoose.models.AdminEmail || mongoose.model('AdminEmail', AdminEmailSchema);
|
|
38
|
-
|
|
1
|
+
import mongoose, { Schema, model } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const AdminEmailSchema = new Schema({
|
|
4
|
+
email: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true,
|
|
8
|
+
lowercase: true,
|
|
9
|
+
trim: true
|
|
10
|
+
},
|
|
11
|
+
isActive: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: true
|
|
14
|
+
},
|
|
15
|
+
permissions: {
|
|
16
|
+
shoppableVideo: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
productAccess: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
totalAccess: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
timestamps: true
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Index for faster querying
|
|
34
|
+
AdminEmailSchema.index({ email: 1, isActive: 1 });
|
|
35
|
+
|
|
36
|
+
// Export safely
|
|
37
|
+
const AdminEmail = mongoose.models.AdminEmail || mongoose.model('AdminEmail', AdminEmailSchema);
|
|
38
|
+
|
|
39
39
|
export default AdminEmail;
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
// config/devModel/BankVerification.js
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
const bankVerificationSchema = new mongoose.Schema({
|
|
5
|
-
userId: {
|
|
6
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
-
ref: 'users',
|
|
8
|
-
required: true,
|
|
9
|
-
unique: true, // Ensures only one bank verification per user
|
|
10
|
-
index: true
|
|
11
|
-
},
|
|
12
|
-
sellerId: {
|
|
13
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
-
ref: 'sellers',
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
role: {
|
|
18
|
-
type: String,
|
|
19
|
-
enum: ['user', 'seller', 'admin'],
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
accountNumber: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true
|
|
25
|
-
},
|
|
26
|
-
ifscCode: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: true
|
|
29
|
-
},
|
|
30
|
-
verificationStatus: {
|
|
31
|
-
type: String,
|
|
32
|
-
enum: ['pending', 'verified', 'failed'],
|
|
33
|
-
default: 'pending'
|
|
34
|
-
},
|
|
35
|
-
accountHolderName: {
|
|
36
|
-
type: String,
|
|
37
|
-
default: null
|
|
38
|
-
},
|
|
39
|
-
nameMatch: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
default: false
|
|
42
|
-
},
|
|
43
|
-
accountStatus: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: null
|
|
46
|
-
},
|
|
47
|
-
accountType: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: null
|
|
50
|
-
},
|
|
51
|
-
bankName: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: null
|
|
54
|
-
},
|
|
55
|
-
branchName: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: null
|
|
58
|
-
},
|
|
59
|
-
branchAddress: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: null
|
|
62
|
-
},
|
|
63
|
-
accountExists: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false
|
|
66
|
-
},
|
|
67
|
-
referenceId: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: null
|
|
70
|
-
},
|
|
71
|
-
verificationDate: {
|
|
72
|
-
type: Date,
|
|
73
|
-
default: Date.now
|
|
74
|
-
},
|
|
75
|
-
verifiedAt: {
|
|
76
|
-
type: Date,
|
|
77
|
-
default: null
|
|
78
|
-
},
|
|
79
|
-
rawResponse: {
|
|
80
|
-
type: mongoose.Schema.Types.Mixed,
|
|
81
|
-
default: null
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
timestamps: true
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Indexes for better query performance
|
|
88
|
-
bankVerificationSchema.index({ userId: 1, verificationStatus: 1 });
|
|
89
|
-
bankVerificationSchema.index({ accountNumber: 1, ifscCode: 1 });
|
|
90
|
-
const BankVerification = mongoose.models.BankVerification || mongoose.model("BankVerification", bankVerificationSchema);
|
|
91
|
-
|
|
92
|
-
export default BankVerification;
|
|
1
|
+
// config/devModel/BankVerification.js
|
|
2
|
+
import mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
const bankVerificationSchema = new mongoose.Schema({
|
|
5
|
+
userId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'users',
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true, // Ensures only one bank verification per user
|
|
10
|
+
index: true
|
|
11
|
+
},
|
|
12
|
+
sellerId: {
|
|
13
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
+
ref: 'sellers',
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
role: {
|
|
18
|
+
type: String,
|
|
19
|
+
enum: ['user', 'seller', 'admin'],
|
|
20
|
+
|
|
21
|
+
},
|
|
22
|
+
accountNumber: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
ifscCode: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
verificationStatus: {
|
|
31
|
+
type: String,
|
|
32
|
+
enum: ['pending', 'verified', 'failed'],
|
|
33
|
+
default: 'pending'
|
|
34
|
+
},
|
|
35
|
+
accountHolderName: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
39
|
+
nameMatch: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
accountStatus: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: null
|
|
46
|
+
},
|
|
47
|
+
accountType: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: null
|
|
50
|
+
},
|
|
51
|
+
bankName: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: null
|
|
54
|
+
},
|
|
55
|
+
branchName: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: null
|
|
58
|
+
},
|
|
59
|
+
branchAddress: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: null
|
|
62
|
+
},
|
|
63
|
+
accountExists: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false
|
|
66
|
+
},
|
|
67
|
+
referenceId: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: null
|
|
70
|
+
},
|
|
71
|
+
verificationDate: {
|
|
72
|
+
type: Date,
|
|
73
|
+
default: Date.now
|
|
74
|
+
},
|
|
75
|
+
verifiedAt: {
|
|
76
|
+
type: Date,
|
|
77
|
+
default: null
|
|
78
|
+
},
|
|
79
|
+
rawResponse: {
|
|
80
|
+
type: mongoose.Schema.Types.Mixed,
|
|
81
|
+
default: null
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
timestamps: true
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Indexes for better query performance
|
|
88
|
+
bankVerificationSchema.index({ userId: 1, verificationStatus: 1 });
|
|
89
|
+
bankVerificationSchema.index({ accountNumber: 1, ifscCode: 1 });
|
|
90
|
+
const BankVerification = mongoose.models.BankVerification || mongoose.model("BankVerification", bankVerificationSchema);
|
|
91
|
+
|
|
92
|
+
export default BankVerification;
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
// models/GSTVerification.js
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
const gstVerificationSchema = new mongoose.Schema({
|
|
5
|
-
userId: {
|
|
6
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
-
ref: 'users',
|
|
8
|
-
required: true,
|
|
9
|
-
index: true
|
|
10
|
-
},
|
|
11
|
-
gstNumber: {
|
|
12
|
-
type: String,
|
|
13
|
-
required: true,
|
|
14
|
-
uppercase: true,
|
|
15
|
-
trim: true
|
|
16
|
-
},
|
|
17
|
-
verificationStatus: {
|
|
18
|
-
type: String,
|
|
19
|
-
enum: ['verified', 'pending', 'failed'],
|
|
20
|
-
default: 'pending'
|
|
21
|
-
},
|
|
22
|
-
businessName: {
|
|
23
|
-
type: String,
|
|
24
|
-
trim: true
|
|
25
|
-
},
|
|
26
|
-
tradeName: {
|
|
27
|
-
type: String,
|
|
28
|
-
trim: true
|
|
29
|
-
},
|
|
30
|
-
gstStatus: {
|
|
31
|
-
type: String,
|
|
32
|
-
trim: true
|
|
33
|
-
},
|
|
34
|
-
registrationDate: {
|
|
35
|
-
type: Date
|
|
36
|
-
},
|
|
37
|
-
businessType: {
|
|
38
|
-
type: String,
|
|
39
|
-
trim: true
|
|
40
|
-
},
|
|
41
|
-
constitution: {
|
|
42
|
-
type: String,
|
|
43
|
-
trim: true
|
|
44
|
-
},
|
|
45
|
-
taxpayerType: {
|
|
46
|
-
type: String,
|
|
47
|
-
trim: true
|
|
48
|
-
},
|
|
49
|
-
address: {
|
|
50
|
-
building: String,
|
|
51
|
-
street: String,
|
|
52
|
-
location: String,
|
|
53
|
-
district: String,
|
|
54
|
-
state: String,
|
|
55
|
-
pincode: String,
|
|
56
|
-
city: String,
|
|
57
|
-
floor: String
|
|
58
|
-
},
|
|
59
|
-
filingStatus: {
|
|
60
|
-
type: String,
|
|
61
|
-
trim: true
|
|
62
|
-
},
|
|
63
|
-
lastUpdated: {
|
|
64
|
-
type: Date
|
|
65
|
-
},
|
|
66
|
-
cancellationDate: {
|
|
67
|
-
type: Date
|
|
68
|
-
},
|
|
69
|
-
rawResponse: {
|
|
70
|
-
type: mongoose.Schema.Types.Mixed
|
|
71
|
-
},
|
|
72
|
-
verificationDate: {
|
|
73
|
-
type: Date,
|
|
74
|
-
default: Date.now
|
|
75
|
-
},
|
|
76
|
-
isActive: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
default: true
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
timestamps: true
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Compound index to prevent duplicate verifications for same user and GST
|
|
85
|
-
gstVerificationSchema.index({ userId: 1, gstNumber: 1 }, { unique: true });
|
|
86
|
-
|
|
87
|
-
const GSTVerification = mongoose.models.GSTVerification || mongoose.model("GSTVerification", gstVerificationSchema);
|
|
88
|
-
|
|
89
|
-
export default GSTVerification;
|
|
1
|
+
// models/GSTVerification.js
|
|
2
|
+
import mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
const gstVerificationSchema = new mongoose.Schema({
|
|
5
|
+
userId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'users',
|
|
8
|
+
required: true,
|
|
9
|
+
index: true
|
|
10
|
+
},
|
|
11
|
+
gstNumber: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
uppercase: true,
|
|
15
|
+
trim: true
|
|
16
|
+
},
|
|
17
|
+
verificationStatus: {
|
|
18
|
+
type: String,
|
|
19
|
+
enum: ['verified', 'pending', 'failed'],
|
|
20
|
+
default: 'pending'
|
|
21
|
+
},
|
|
22
|
+
businessName: {
|
|
23
|
+
type: String,
|
|
24
|
+
trim: true
|
|
25
|
+
},
|
|
26
|
+
tradeName: {
|
|
27
|
+
type: String,
|
|
28
|
+
trim: true
|
|
29
|
+
},
|
|
30
|
+
gstStatus: {
|
|
31
|
+
type: String,
|
|
32
|
+
trim: true
|
|
33
|
+
},
|
|
34
|
+
registrationDate: {
|
|
35
|
+
type: Date
|
|
36
|
+
},
|
|
37
|
+
businessType: {
|
|
38
|
+
type: String,
|
|
39
|
+
trim: true
|
|
40
|
+
},
|
|
41
|
+
constitution: {
|
|
42
|
+
type: String,
|
|
43
|
+
trim: true
|
|
44
|
+
},
|
|
45
|
+
taxpayerType: {
|
|
46
|
+
type: String,
|
|
47
|
+
trim: true
|
|
48
|
+
},
|
|
49
|
+
address: {
|
|
50
|
+
building: String,
|
|
51
|
+
street: String,
|
|
52
|
+
location: String,
|
|
53
|
+
district: String,
|
|
54
|
+
state: String,
|
|
55
|
+
pincode: String,
|
|
56
|
+
city: String,
|
|
57
|
+
floor: String
|
|
58
|
+
},
|
|
59
|
+
filingStatus: {
|
|
60
|
+
type: String,
|
|
61
|
+
trim: true
|
|
62
|
+
},
|
|
63
|
+
lastUpdated: {
|
|
64
|
+
type: Date
|
|
65
|
+
},
|
|
66
|
+
cancellationDate: {
|
|
67
|
+
type: Date
|
|
68
|
+
},
|
|
69
|
+
rawResponse: {
|
|
70
|
+
type: mongoose.Schema.Types.Mixed
|
|
71
|
+
},
|
|
72
|
+
verificationDate: {
|
|
73
|
+
type: Date,
|
|
74
|
+
default: Date.now
|
|
75
|
+
},
|
|
76
|
+
isActive: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: true
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
timestamps: true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Compound index to prevent duplicate verifications for same user and GST
|
|
85
|
+
gstVerificationSchema.index({ userId: 1, gstNumber: 1 }, { unique: true });
|
|
86
|
+
|
|
87
|
+
const GSTVerification = mongoose.models.GSTVerification || mongoose.model("GSTVerification", gstVerificationSchema);
|
|
88
|
+
|
|
89
|
+
export default GSTVerification;
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import mongoose, { Schema, model } from 'mongoose';
|
|
2
|
-
|
|
3
|
-
import crypto from 'crypto';
|
|
4
|
-
|
|
5
|
-
const liveStreamInteractionSchema = new mongoose.Schema({
|
|
6
|
-
show: {
|
|
7
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
8
|
-
ref: 'shows',
|
|
9
|
-
required: true
|
|
10
|
-
},
|
|
11
|
-
user: {
|
|
12
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
-
ref: 'User',
|
|
14
|
-
index: true
|
|
15
|
-
},
|
|
16
|
-
sessionIdentifier: {
|
|
17
|
-
type: String,
|
|
18
|
-
index: true
|
|
19
|
-
},
|
|
20
|
-
host: {
|
|
21
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
-
refPath: 'hostModel',
|
|
23
|
-
required: true
|
|
24
|
-
},
|
|
25
|
-
hostModel: {
|
|
26
|
-
type: String,
|
|
27
|
-
required: true,
|
|
28
|
-
enum: ['sellers', 'dropshippers']
|
|
29
|
-
},
|
|
30
|
-
location: {
|
|
31
|
-
city: String,
|
|
32
|
-
region: String,
|
|
33
|
-
country: String
|
|
34
|
-
},
|
|
35
|
-
platform: {
|
|
36
|
-
type: String,
|
|
37
|
-
enum: ['web', 'mobile', 'unknown'],
|
|
38
|
-
default: 'unknown'
|
|
39
|
-
},
|
|
40
|
-
device: {
|
|
41
|
-
type: String,
|
|
42
|
-
enum: ['mobile', 'desktop', 'tablet', 'other', 'unknown'],
|
|
43
|
-
default: 'unknown'
|
|
44
|
-
},
|
|
45
|
-
browser: String,
|
|
46
|
-
os: String,
|
|
47
|
-
ip: {
|
|
48
|
-
type: String,
|
|
49
|
-
required: true
|
|
50
|
-
},
|
|
51
|
-
watchDuration: {
|
|
52
|
-
type: Number,
|
|
53
|
-
default: 0
|
|
54
|
-
},
|
|
55
|
-
lastSeenAt: Date,
|
|
56
|
-
hasLiked: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false
|
|
59
|
-
},
|
|
60
|
-
buyNowClicked: [{
|
|
61
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
62
|
-
ref: 'productlistings'
|
|
63
|
-
}],
|
|
64
|
-
auctionBidded: [{
|
|
65
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
66
|
-
ref: 'productlistings'
|
|
67
|
-
}],
|
|
68
|
-
giveawayEntered: [{
|
|
69
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
70
|
-
ref: 'productlistings'
|
|
71
|
-
}],
|
|
72
|
-
auctionBids: [{
|
|
73
|
-
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'productlistings' },
|
|
74
|
-
bidAmount: { type: Number, required: true },
|
|
75
|
-
bidTime: { type: Date, default: Date.now }
|
|
76
|
-
}],
|
|
77
|
-
giveawayEntries: [{
|
|
78
|
-
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'productlistings' },
|
|
79
|
-
entryTime: { type: Date, default: Date.now }
|
|
80
|
-
}]
|
|
81
|
-
}, {
|
|
82
|
-
timestamps: true
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Unique indexes
|
|
86
|
-
liveStreamInteractionSchema.index({ show: 1, user: 1 }, {
|
|
87
|
-
unique: true,
|
|
88
|
-
partialFilterExpression: { user: { $exists: true } }
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
liveStreamInteractionSchema.index({ show: 1, sessionIdentifier: 1 }, {
|
|
92
|
-
unique: true,
|
|
93
|
-
partialFilterExpression: { sessionIdentifier: { $exists: true } }
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
liveStreamInteractionSchema.index({ show: 1, createdAt: -1 });
|
|
97
|
-
|
|
98
|
-
// Safe export to prevent OverwriteModelError
|
|
99
|
-
const LiveStreamInteraction = mongoose.models.LiveStreamInteraction || mongoose.model('LiveStreamInteraction', liveStreamInteractionSchema);
|
|
100
|
-
|
|
101
|
-
export default LiveStreamInteraction;
|
|
1
|
+
import mongoose, { Schema, model } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
|
|
5
|
+
const liveStreamInteractionSchema = new mongoose.Schema({
|
|
6
|
+
show: {
|
|
7
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
8
|
+
ref: 'shows',
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
user: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'User',
|
|
14
|
+
index: true
|
|
15
|
+
},
|
|
16
|
+
sessionIdentifier: {
|
|
17
|
+
type: String,
|
|
18
|
+
index: true
|
|
19
|
+
},
|
|
20
|
+
host: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
refPath: 'hostModel',
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
hostModel: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true,
|
|
28
|
+
enum: ['sellers', 'dropshippers']
|
|
29
|
+
},
|
|
30
|
+
location: {
|
|
31
|
+
city: String,
|
|
32
|
+
region: String,
|
|
33
|
+
country: String
|
|
34
|
+
},
|
|
35
|
+
platform: {
|
|
36
|
+
type: String,
|
|
37
|
+
enum: ['web', 'mobile', 'unknown'],
|
|
38
|
+
default: 'unknown'
|
|
39
|
+
},
|
|
40
|
+
device: {
|
|
41
|
+
type: String,
|
|
42
|
+
enum: ['mobile', 'desktop', 'tablet', 'other', 'unknown'],
|
|
43
|
+
default: 'unknown'
|
|
44
|
+
},
|
|
45
|
+
browser: String,
|
|
46
|
+
os: String,
|
|
47
|
+
ip: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
watchDuration: {
|
|
52
|
+
type: Number,
|
|
53
|
+
default: 0
|
|
54
|
+
},
|
|
55
|
+
lastSeenAt: Date,
|
|
56
|
+
hasLiked: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
buyNowClicked: [{
|
|
61
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
62
|
+
ref: 'productlistings'
|
|
63
|
+
}],
|
|
64
|
+
auctionBidded: [{
|
|
65
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
66
|
+
ref: 'productlistings'
|
|
67
|
+
}],
|
|
68
|
+
giveawayEntered: [{
|
|
69
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
70
|
+
ref: 'productlistings'
|
|
71
|
+
}],
|
|
72
|
+
auctionBids: [{
|
|
73
|
+
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'productlistings' },
|
|
74
|
+
bidAmount: { type: Number, required: true },
|
|
75
|
+
bidTime: { type: Date, default: Date.now }
|
|
76
|
+
}],
|
|
77
|
+
giveawayEntries: [{
|
|
78
|
+
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'productlistings' },
|
|
79
|
+
entryTime: { type: Date, default: Date.now }
|
|
80
|
+
}]
|
|
81
|
+
}, {
|
|
82
|
+
timestamps: true
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Unique indexes
|
|
86
|
+
liveStreamInteractionSchema.index({ show: 1, user: 1 }, {
|
|
87
|
+
unique: true,
|
|
88
|
+
partialFilterExpression: { user: { $exists: true } }
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
liveStreamInteractionSchema.index({ show: 1, sessionIdentifier: 1 }, {
|
|
92
|
+
unique: true,
|
|
93
|
+
partialFilterExpression: { sessionIdentifier: { $exists: true } }
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
liveStreamInteractionSchema.index({ show: 1, createdAt: -1 });
|
|
97
|
+
|
|
98
|
+
// Safe export to prevent OverwriteModelError
|
|
99
|
+
const LiveStreamInteraction = mongoose.models.LiveStreamInteraction || mongoose.model('LiveStreamInteraction', liveStreamInteractionSchema);
|
|
100
|
+
|
|
101
|
+
export default LiveStreamInteraction;
|