database-connector 2.4.19 → 2.5.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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ### Changed
6
+ - **Categorization Hierarchy Restructure**: Refactored category models to implement new hierarchy: StoreCategory → Rayon → Sub-rayon → Category → Sub-category
7
+ - **StoreCategory Model**: Removed `rayonId` field as StoreCategory is now the top-level category
8
+ - **Rayon Model**: Added `storeCategoryId` field (required) to associate rayons with store categories
9
+ - **Category Model**: Added `rayonId` field (required) to associate categories with rayons or sub-rayons
10
+ - **Product Model**: Maintains `storeCategoryId`, `categoryId`, `subCategoryId`, `rayonId`, and `subRayonId` for full hierarchy tracking
11
+ - Updated Swagger documentation for all affected models
12
+ - Updated DATABASE_SCHEMA.md to reflect new relationships in ER diagram
13
+
5
14
  ### Added
6
15
  - **PlanType Model**: Created new `PlanType` model for plan categorization and feature management
7
16
  - Schema includes `name` (unique, required), `endDate` (optional, nullable), `active` (boolean, default: true), and `features` (Map of string keys to Mixed values - boolean or number)
@@ -15,6 +15,9 @@ const mongoose = require('mongoose');
15
15
  * storeCategoryId:
16
16
  * type: string
17
17
  * description: Reference to store category
18
+ * rayonId:
19
+ * type: string
20
+ * description: Reference to rayon or sub-rayon (ObjectId)
18
21
  * name:
19
22
  * type: string
20
23
  * description: Category name
@@ -51,6 +54,10 @@ const categorySchema = new mongoose.Schema(
51
54
  type: mongoose.Schema.Types.ObjectId,
52
55
  ref: 'StoreCategory',
53
56
  },
57
+ rayonId: {
58
+ type: mongoose.Schema.Types.ObjectId,
59
+ default: null,
60
+ },
54
61
  name: {
55
62
  type: String,
56
63
  required: true,
package/models/Payment.js CHANGED
@@ -104,6 +104,7 @@ const paymentSchema = new mongoose.Schema(
104
104
  paymentCurrency: {
105
105
  type: String,
106
106
  required: true,
107
+ default: 'EUR',
107
108
  },
108
109
  paymentMethodId: {
109
110
  type: mongoose.Schema.Types.ObjectId,
package/models/Rayon.js CHANGED
@@ -12,6 +12,9 @@ const mongoose = require('mongoose');
12
12
  * id:
13
13
  * type: string
14
14
  * description: The rayon identifier
15
+ * storeCategoryId:
16
+ * type: string
17
+ * description: Reference to store category
15
18
  * name:
16
19
  * type: string
17
20
  * description: Rayon name
@@ -54,6 +57,11 @@ const mongoose = require('mongoose');
54
57
  */
55
58
  const rayonSchema = new mongoose.Schema(
56
59
  {
60
+ storeCategoryId: {
61
+ type: mongoose.Schema.Types.ObjectId,
62
+ ref: 'StoreCategory',
63
+ required: true,
64
+ },
57
65
  name: {
58
66
  type: String,
59
67
  required: true,
@@ -19,10 +19,6 @@ const mongoose = require('mongoose');
19
19
  * type: boolean
20
20
  * default: false
21
21
  * description: Whether the category is confirmed
22
- * rayonId:
23
- * type: string
24
- * nullable: true
25
- * description: Reference to rayon or sub-rayon (ObjectId)
26
22
  * createdAt:
27
23
  * type: string
28
24
  * format: date-time
@@ -43,10 +39,6 @@ const storeCategorySchema = new mongoose.Schema(
43
39
  required: true
44
40
  },
45
41
  confirmed: { type: Boolean, default: false },
46
- rayonId: {
47
- type: mongoose.Schema.Types.ObjectId,
48
- default: null,
49
- },
50
42
  },
51
43
  { timestamps: true, toJSON: { virtuals: true } }
52
44
  );
package/models/User.js CHANGED
@@ -104,6 +104,10 @@ const { policySchema } = require('database-connector/models/Policy');
104
104
  * enum: [ar, en, fr]
105
105
  * default: en
106
106
  * description: User's preferred language
107
+ * currency:
108
+ * type: string
109
+ * default: EUR
110
+ * description: User's preferred currency (EUR, USD, DZD, etc.)
107
111
  * storeCategorieIds:
108
112
  * type: array
109
113
  * items:
@@ -253,6 +257,10 @@ const userSchema = new mongoose.Schema(
253
257
  enum: ['ar', 'en', 'fr'],
254
258
  default: 'en',
255
259
  },
260
+ currency: {
261
+ type: String,
262
+ default: 'EUR',
263
+ },
256
264
  storeCategorieIds: [
257
265
  {
258
266
  type: mongoose.Schema.Types.ObjectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.4.19",
3
+ "version": "2.5.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": {