teamplay 0.3.3 → 0.3.4

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.
@@ -50,12 +50,11 @@ export function isAggregationSignal ($signal) {
50
50
 
51
51
  // example: ['$aggregations', '{"active":true}', 42]
52
52
  // AND only if it also has either '_id' or 'id' field inside
53
- export function getAggregationDocId (segments) {
53
+ export function getAggregationDocId (segments, method = getRaw) {
54
54
  if (!(segments.length >= 3)) return
55
55
  if (!(segments[0] === AGGREGATIONS)) return
56
56
  if (!(typeof segments[2] === 'number')) return
57
- const doc = getRaw(segments.slice(0, 3))
58
- const docId = doc?._id || doc?.id
57
+ const docId = method([...segments.slice(0, 3), '_id']) || method([...segments.slice(0, 3), 'id'])
59
58
  return docId
60
59
  }
61
60
 
package/orm/Signal.js CHANGED
@@ -79,6 +79,11 @@ export default class Signal extends Function {
79
79
  getId () {
80
80
  if (this[SEGMENTS].length === 0) throw Error('Can\'t get the id of the root signal')
81
81
  if (this[SEGMENTS].length === 1) throw Error('Can\'t get the id of a collection')
82
+ if (this[SEGMENTS][0] === AGGREGATIONS && this[SEGMENTS].length === 3) {
83
+ // use get() instead of the default getRaw() to trigger observability on changes
84
+ // This is required since within aggregation array results docs can change their position
85
+ return getAggregationDocId(this[SEGMENTS], _get)
86
+ }
82
87
  return this[SEGMENTS][this[SEGMENTS].length - 1]
83
88
  }
84
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamplay",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Full-stack signals ORM with multiplayer",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@nx-js/observer-util": "^4.1.3",
26
- "@teamplay/backend": "^0.3.3",
27
- "@teamplay/cache": "^0.3.3",
28
- "@teamplay/channel": "^0.3.3",
29
- "@teamplay/debug": "^0.3.3",
30
- "@teamplay/schema": "^0.3.3",
31
- "@teamplay/utils": "^0.3.3",
26
+ "@teamplay/backend": "^0.3.4",
27
+ "@teamplay/cache": "^0.3.4",
28
+ "@teamplay/channel": "^0.3.4",
29
+ "@teamplay/debug": "^0.3.4",
30
+ "@teamplay/schema": "^0.3.4",
31
+ "@teamplay/utils": "^0.3.4",
32
32
  "diff-match-patch": "^1.0.5",
33
33
  "events": "^3.3.0",
34
34
  "json0-ot-diff": "^1.1.2",
@@ -63,5 +63,5 @@
63
63
  ]
64
64
  },
65
65
  "license": "MIT",
66
- "gitHead": "3cb65f144eafd59cbb646328e503f4747df98279"
66
+ "gitHead": "108c0d37aea7cbe37686fafaf129e941937d7707"
67
67
  }