@livequery/client 2.0.25 → 2.0.31
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/build/Collection.d.ts +1 -0
- package/build/Collection.js +7 -6
- package/package.json +1 -1
package/build/Collection.d.ts
CHANGED
package/build/Collection.js
CHANGED
|
@@ -15,6 +15,7 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
15
15
|
}
|
|
16
16
|
constructor(ref, collection_options) {
|
|
17
17
|
super({
|
|
18
|
+
n: 0,
|
|
18
19
|
items: [],
|
|
19
20
|
loading: false,
|
|
20
21
|
paging: {},
|
|
@@ -50,6 +51,7 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
50
51
|
for (const { data, error, code, message, } of stream) {
|
|
51
52
|
if (from == 'request') {
|
|
52
53
|
state.loading = false;
|
|
54
|
+
state.n = state.n + 1;
|
|
53
55
|
}
|
|
54
56
|
// Error & paging
|
|
55
57
|
if (error) {
|
|
@@ -75,13 +77,12 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
75
77
|
// Is realtime update that match filters
|
|
76
78
|
from == 'realtime' && Object
|
|
77
79
|
.keys(state.options || {})
|
|
78
|
-
.filter(key => !key.
|
|
80
|
+
.filter(key => !key.startsWith(':'))
|
|
79
81
|
.every(key => {
|
|
80
82
|
const [field, expression] = key.split(':');
|
|
81
83
|
const a = payload[field];
|
|
82
84
|
const b = state.options?.[field];
|
|
83
85
|
const map = {
|
|
84
|
-
'default': () => a == b,
|
|
85
86
|
eq: () => a == b,
|
|
86
87
|
ne: () => a != b,
|
|
87
88
|
lt: () => typeof a == 'number' && typeof b == 'number' && a < b,
|
|
@@ -93,12 +94,12 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
93
94
|
between: () => typeof a == 'number' && Array.isArray(b) && typeof b[0] == 'number' && b[0] <= a && typeof b[1] == 'number' && a <= b[1]
|
|
94
95
|
};
|
|
95
96
|
try {
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
return
|
|
97
|
+
const expr = expression == '' ? 'eq' : expression;
|
|
98
|
+
if (map[expr])
|
|
99
|
+
return map[expr]();
|
|
99
100
|
}
|
|
100
101
|
catch (e) { }
|
|
101
|
-
return
|
|
102
|
+
return true;
|
|
102
103
|
}))) {
|
|
103
104
|
const item = {
|
|
104
105
|
...payload,
|