@pintahub/database-schemas 4.8.1 → 5.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/database-schemas",
3
- "version": "4.8.1",
3
+ "version": "5.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,21 +6,18 @@ const StoreEvent = new Schema({
6
6
  /** @ref Store */
7
7
  store: {
8
8
  type: Schema.Types.ObjectId,
9
- index: true,
10
9
  required: true,
11
10
  },
12
11
 
13
12
  /** @ref Product — related product (if applicable) */
14
13
  product: {
15
14
  type: Schema.Types.ObjectId,
16
- index: true,
17
15
  },
18
16
 
19
17
  /** Visitor session identifier */
20
18
  session_id: {
21
19
  type: String,
22
20
  trim: true,
23
- index: true,
24
21
  },
25
22
 
26
23
  /** Event name, e.g. 'page_view', 'add_to_cart', 'purchase' */
@@ -28,7 +25,6 @@ const StoreEvent = new Schema({
28
25
  type: String,
29
26
  trim: true,
30
27
  lowercase: true,
31
- index: true,
32
28
  },
33
29
 
34
30
  /** URL */
@@ -46,7 +42,6 @@ const StoreEvent = new Schema({
46
42
  country: {
47
43
  type: String,
48
44
  trim: true,
49
- index: true,
50
45
  uppercase: true,
51
46
  },
52
47
 
@@ -73,16 +68,20 @@ const StoreEvent = new Schema({
73
68
  referrer_domain: {
74
69
  type: String,
75
70
  trim: true,
76
- index: true,
77
71
  },
78
72
 
79
73
  /** Record creation timestamp */
80
74
  created_at: {
81
75
  type: Date,
82
76
  default: Date.now,
83
- index: true,
84
77
  }
85
78
  })
86
79
 
80
+ // Primary — cover admin /stats/* queries (store + name + time range)
81
+ StoreEvent.index({store: 1, name: 1, created_at: -1})
82
+
83
+ // Product-specific — for productViewsCount
84
+ StoreEvent.index({store: 1, product: 1, name: 1, created_at: -1})
85
+
87
86
 
88
87
  module.exports = StoreEvent