@pintahub/database-schemas 4.8.0 → 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.0",
3
+ "version": "5.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -419,11 +419,11 @@ Product.searchIndex({
419
419
  // ---- Full-text searchable ----
420
420
  display_title: {
421
421
  type: 'string',
422
- analyzer: 'lucene.standard',
423
- searchAnalyzer: 'lucene.standard',
422
+ analyzer: 'lucene.english',
423
+ searchAnalyzer: 'lucene.english',
424
424
  },
425
425
  tags: [
426
- {type: 'string', analyzer: 'lucene.standard'},
426
+ {type: 'string', analyzer: 'lucene.english'},
427
427
  {type: 'token', normalizer: 'lowercase'},
428
428
  ],
429
429
  code: [
@@ -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