database-connector 2.3.0 → 2.3.1
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/CHANGELOG.md +3 -0
- package/models/Cart.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
6
|
|
|
7
|
+
#### Added Transaction method to all models
|
|
8
|
+
- Added a static `withTransaction(fn)` method to all models to facilitate running operations within MongoDB transactions. This method accepts a function `fn` that contains the operations to be executed in a transaction.
|
|
9
|
+
|
|
7
10
|
#### Database Indexes for Performance Optimization
|
|
8
11
|
|
|
9
12
|
After comprehensive analysis of model usage across all microservices (AuthService, CartService, CategoryService, NotificationService, OfferService, OrderService, ProductService, SalesAnalyticsService, SearchExplorationService, StoreService, SubscriptionService, and UserService), the following database indexes have been added to optimize query performance:
|
package/models/Cart.js
CHANGED
|
@@ -22,6 +22,10 @@ const { Schema, model } = require('mongoose');
|
|
|
22
22
|
* type: string
|
|
23
23
|
* variantId:
|
|
24
24
|
* type: string
|
|
25
|
+
* offerId:
|
|
26
|
+
* type: string
|
|
27
|
+
* nullable: true
|
|
28
|
+
* description: Reference to an offer (optional)
|
|
25
29
|
* discount:
|
|
26
30
|
* type: number
|
|
27
31
|
* default: 0
|
|
@@ -57,6 +61,7 @@ const itemSchema = new Schema(
|
|
|
57
61
|
{
|
|
58
62
|
productId: { type: Schema.Types.ObjectId, ref: 'Product', required: true },
|
|
59
63
|
variantId: { type: String, required: true },
|
|
64
|
+
offer: { type: Schema.Types.ObjectId, ref: 'Offer', default: null },
|
|
60
65
|
discount: { type: Number, default: 0 },
|
|
61
66
|
quantity: { type: Number, required: true, default: 1 },
|
|
62
67
|
discountQuantity: { type: Number, default: 0 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "database-connector",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
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": {
|