database-connector 2.2.3 → 2.2.5
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/models/Product.js +23 -23
- package/models/Store.js +12 -6
- package/package.json +1 -1
package/models/Product.js
CHANGED
|
@@ -259,16 +259,16 @@ productSchema.virtual('PriceMax').get(function () {
|
|
|
259
259
|
*/
|
|
260
260
|
|
|
261
261
|
// Virtual: array of all product images with full URLs
|
|
262
|
-
productSchema.virtual('imagesss').get(function () {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
});
|
|
262
|
+
// productSchema.virtual('imagesss').get(function () {
|
|
263
|
+
// if (this.images != null) {
|
|
264
|
+
// const images = this.images;
|
|
265
|
+
// console.log(images);
|
|
266
|
+
// console.log('images');
|
|
267
|
+
// return images.map(function (image) {
|
|
268
|
+
// return `${getBaseURL()}/${image}`;
|
|
269
|
+
// });
|
|
270
|
+
// }
|
|
271
|
+
// });
|
|
272
272
|
|
|
273
273
|
// Virtual: discounted price
|
|
274
274
|
productSchema.virtual('discounted').get(function () {
|
|
@@ -281,19 +281,19 @@ productSchema.virtual('discounted').get(function () {
|
|
|
281
281
|
});
|
|
282
282
|
|
|
283
283
|
// Virtual: array of all variant images with full URLs
|
|
284
|
-
productSchema.virtual('variantImages').get(function () {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
});
|
|
284
|
+
// productSchema.virtual('variantImages').get(function () {
|
|
285
|
+
// if (this.variants != null) {
|
|
286
|
+
// const variants = this.variants;
|
|
287
|
+
// console.log(variants);
|
|
288
|
+
// return variants.map(function (variant) {
|
|
289
|
+
// if (variant.img != null) {
|
|
290
|
+
// return `${getBaseURL()}/${variant.img}`;
|
|
291
|
+
// } else {
|
|
292
|
+
// return `${getBaseURL()}${getDefaultImagePath()}`;
|
|
293
|
+
// }
|
|
294
|
+
// });
|
|
295
|
+
// }
|
|
296
|
+
// });
|
|
297
297
|
|
|
298
298
|
// Indexes for performance optimization
|
|
299
299
|
productSchema.index({ storeId: 1, deleted: 1 });
|
package/models/Store.js
CHANGED
|
@@ -60,6 +60,9 @@ const { getBaseURL, getDefaultStoreImagePath } = require('../config');
|
|
|
60
60
|
* description:
|
|
61
61
|
* type: string
|
|
62
62
|
* description: Store description
|
|
63
|
+
* registrationNumber:
|
|
64
|
+
* type: string
|
|
65
|
+
* description: Store registration number
|
|
63
66
|
* isActive:
|
|
64
67
|
* type: boolean
|
|
65
68
|
* default: true
|
|
@@ -269,6 +272,9 @@ const storeSchema = new mongoose.Schema(
|
|
|
269
272
|
type: String,
|
|
270
273
|
required: true,
|
|
271
274
|
},
|
|
275
|
+
registrationNumber: {
|
|
276
|
+
type: String,
|
|
277
|
+
},
|
|
272
278
|
ratingCount: {
|
|
273
279
|
type: Number,
|
|
274
280
|
default: 0,
|
|
@@ -373,12 +379,12 @@ const storeSchema = new mongoose.Schema(
|
|
|
373
379
|
{ timestamps: true, toJSON: { virtuals: true } }
|
|
374
380
|
);
|
|
375
381
|
// Virtual: image URL with base path
|
|
376
|
-
storeSchema.virtual('imageUrl').get(function () {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
});
|
|
382
|
+
// storeSchema.virtual('imageUrl').get(function () {
|
|
383
|
+
// if (this.image != null) {
|
|
384
|
+
// return `${getBaseURL()}/${this.image}`;
|
|
385
|
+
// }
|
|
386
|
+
// return `${getBaseURL()}${getDefaultStoreImagePath()}`;
|
|
387
|
+
// });
|
|
382
388
|
//virtual rating
|
|
383
389
|
storeSchema.virtual('rating').get(function () {
|
|
384
390
|
if (this.ratingSum != 0 && this.ratingCount != 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "database-connector",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "MongoDB models package with Mongoose schemas for e-commerce applications. Includes User, Product, Store, Order and more with built-in validation and virtual properties.",
|
|
5
5
|
"main": "models/index.js",
|
|
6
6
|
"scripts": {
|