flykup_model_development 3.1.8 → 3.1.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.
|
@@ -59,3 +59,50 @@ productInteractionSchema.index({ createdAt: -1 });
|
|
|
59
59
|
// Safe export to prevent OverwriteModelError
|
|
60
60
|
const ProductInteraction = mongoose.models.ProductInteraction || mongoose.model('ProductInteraction', productInteractionSchema);
|
|
61
61
|
export default ProductInteraction;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// import mongoose, { Schema, model } from 'mongoose';
|
|
67
|
+
|
|
68
|
+
// const productInteractionSchema = new mongoose.Schema({
|
|
69
|
+
// product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true },
|
|
70
|
+
// user: { type: mongoose.Schema.Types.ObjectId, ref: 'User', index: true },
|
|
71
|
+
// seller: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller', required: true },
|
|
72
|
+
// location: {
|
|
73
|
+
// city: String,
|
|
74
|
+
// region: String,
|
|
75
|
+
// country: String
|
|
76
|
+
// },
|
|
77
|
+
// // --- NEW FIELD ---
|
|
78
|
+
// platform: { type: String, enum: ['web', 'mobile', 'unknown'], default: 'mobile' },
|
|
79
|
+
// device: { type: String, enum: ['mobile', 'desktop', 'tablet', 'other'] },
|
|
80
|
+
// browser: String,
|
|
81
|
+
// os: String,
|
|
82
|
+
// ip: { type: String, required: true },
|
|
83
|
+
// isIndianRegion: { type: Boolean, default: false },
|
|
84
|
+
// rating: {
|
|
85
|
+
// type: Number,
|
|
86
|
+
// min: 1,
|
|
87
|
+
// max: 5,
|
|
88
|
+
// validate: {
|
|
89
|
+
// validator: Number.isInteger,
|
|
90
|
+
// message: '{VALUE} is not an integer value'
|
|
91
|
+
// }
|
|
92
|
+
// },
|
|
93
|
+
// review: {
|
|
94
|
+
// type: String,
|
|
95
|
+
// maxlength: 500
|
|
96
|
+
// },
|
|
97
|
+
// viewCount: { type: Number, default: 1 }
|
|
98
|
+
// }, { timestamps: true });
|
|
99
|
+
|
|
100
|
+
// // Ensures a user's view is counted only once per product
|
|
101
|
+
// productInteractionSchema.index({ product: 1, user: 1 }, { unique: true, partialFilterExpression: { user: { $exists: true } } });
|
|
102
|
+
|
|
103
|
+
// // Additional indexes for performance
|
|
104
|
+
// productInteractionSchema.index({ createdAt: -1 });
|
|
105
|
+
|
|
106
|
+
// // Safe export to prevent OverwriteModelError
|
|
107
|
+
// const ProductInteraction = mongoose.models.ProductInteraction || mongoose.model('ProductInteraction', productInteractionSchema);
|
|
108
|
+
// export default ProductInteraction;
|
|
@@ -8,6 +8,15 @@ const ProductListingSchema = new Schema(
|
|
|
8
8
|
stockId: { type: Schema.Types.ObjectId, ref: "stocks" },
|
|
9
9
|
title: String,
|
|
10
10
|
description: String,
|
|
11
|
+
flashSale: {
|
|
12
|
+
isActive: { type: Boolean, default: false },
|
|
13
|
+
flashSaleId: { type: mongoose.Schema.Types.ObjectId, ref: 'FlashSale' },
|
|
14
|
+
flashPrice: { type: Number, default: 0 },
|
|
15
|
+
flashStock: { type: Number, default: 0 },
|
|
16
|
+
originalPrice: { type: Number, default: 0 },
|
|
17
|
+
endsAt: { type: Date, default: null },
|
|
18
|
+
startsAt: { type: Date, default: null }
|
|
19
|
+
},
|
|
11
20
|
images: [
|
|
12
21
|
{
|
|
13
22
|
key: { type: String, maxLength: 255, default: null },
|
|
@@ -167,11 +167,31 @@ const ShoppableVideoSchema = new Schema(
|
|
|
167
167
|
type: Number,
|
|
168
168
|
default: 0
|
|
169
169
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
// Admin blocking fields
|
|
171
|
+
isBlocked: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
default: false,
|
|
174
|
+
index: true // For efficient queries of blocked videos
|
|
175
|
+
},
|
|
176
|
+
blockedBy: {
|
|
177
|
+
type: Schema.Types.ObjectId,
|
|
178
|
+
ref: 'Admin',
|
|
179
|
+
default: null
|
|
180
|
+
},
|
|
181
|
+
blockReason: {
|
|
182
|
+
type: String,
|
|
183
|
+
default: null,
|
|
184
|
+
trim: true
|
|
185
|
+
},
|
|
186
|
+
blockedAt: {
|
|
187
|
+
type: Date,
|
|
188
|
+
default: null
|
|
189
|
+
},
|
|
190
|
+
isEligibleToPlay: {
|
|
191
|
+
type: Boolean,
|
|
192
|
+
default: false, // Default to true, can be set to false if video is not eligible for playback
|
|
193
|
+
index: true // Index for quick lookups
|
|
194
|
+
}
|
|
175
195
|
},
|
|
176
196
|
{ timestamps: true }
|
|
177
197
|
);
|