liwi-subscribe-store 9.2.0 → 10.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/CHANGELOG.md +16 -0
- package/dist/{AbstractSubscribableStoreQuery.d.ts → definitions/AbstractSubscribableStoreQuery.d.ts} +0 -0
- package/dist/definitions/AbstractSubscribableStoreQuery.d.ts.map +1 -0
- package/dist/{SubscribeStore.d.ts → definitions/SubscribeStore.d.ts} +2 -2
- package/dist/definitions/SubscribeStore.d.ts.map +1 -0
- package/dist/{index.d.ts → definitions/index.d.ts} +0 -0
- package/dist/definitions/index.d.ts.map +1 -0
- package/dist/index-browser.es.js +0 -82
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern.es.js +1 -32
- package/dist/index-browsermodern.es.js.map +1 -1
- package/dist/{index-node14.mjs → index-node16.mjs} +2 -33
- package/dist/{index-node14.mjs.map → index-node16.mjs.map} +1 -1
- package/package.json +18 -31
- package/src/.eslintrc.json +1 -1
- package/dist/AbstractSubscribableStoreQuery.d.ts.map +0 -1
- package/dist/SubscribeStore.d.ts.map +0 -1
- package/dist/index-browser.cjs.js +0 -545
- package/dist/index-browser.cjs.js.map +0 -1
- package/dist/index-node14.cjs +0 -195
- package/dist/index-node14.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [10.0.0](https://github.com/liwijs/liwi/compare/v9.2.0...v10.0.0) (2022-11-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Code Refactoring
|
|
10
|
+
|
|
11
|
+
* drop node 14 and cjs ([b7035bd](https://github.com/liwijs/liwi/commit/b7035bd2289982ef56d3e560f4f3f308e90a555e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* dropped node 14 and cjs
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [9.2.0](https://github.com/liwijs/liwi/compare/v9.1.0...v9.2.0) (2022-10-29)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package liwi-subscribe-store
|
package/dist/{AbstractSubscribableStoreQuery.d.ts → definitions/AbstractSubscribableStoreQuery.d.ts}
RENAMED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractSubscribableStoreQuery.d.ts","sourceRoot":"","sources":["../../src/AbstractSubscribableStoreQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,8BAA8B,CAC1D,OAAO,SAAS,MAAM,KAAK,EAC3B,QAAQ,SAAS,eAAe,EAChC,KAAK,SAAS,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnD,eAAe,SAAS,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,EAClD,MAAM,SAAS,WAAW,CAAC,MAAM,CAAC,GAAG,KAAK,EAC1C,MAAM,GAAG,KAAK,CACd,YAAW,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;IAE1C,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK;IAInC,mBAAmB,CACjB,MAAM,EAAE,MAAM,SAAS,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,GACzD,KAAK;IAIR,OAAO,CAAC,eAAe,CAAC,CAOtB;IAEF,iBAAiB,CACf,KAAK,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,GACzE,IAAI;IAIP,iBAAiB,IAAI,cAAc,CACjC,OAAO,EACP,QAAQ,EACR,KAAK,EACL,eAAe,EACf,GAAG,EACH,GAAG,CACJ;IAOD,QAAQ,CAAC,KAAK,CAAC,CAAC,EACd,WAAW,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GAC9C,OAAO,CAAC,CAAC,CAAC;IAEb,iBAAiB,CACf,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,GAC5C,iBAAiB;IAIpB,SAAS,CAAC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,iBAAiB;IAI3E,QAAQ,CAAC,UAAU,CACjB,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAC7C,eAAe,EAAE,OAAO,GACvB,iBAAiB;CACrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Store as StoreInterface, AbstractConnection, UpsertResult, SubscribableStoreQuery, AbstractStoreCursor, SubscribableStore, QueryParams, UpsertPartialObject, BaseModel, InsertType, Update, Criteria, Sort, QueryOptions, Transformer, AllowedKeyValue, OptionalBaseModelKeysForInsert } from 'liwi-store';
|
|
2
|
-
export
|
|
2
|
+
export type Actions<Model> = {
|
|
3
3
|
type: 'inserted';
|
|
4
4
|
next: Model[];
|
|
5
5
|
} | {
|
|
@@ -9,7 +9,7 @@ export declare type Actions<Model> = {
|
|
|
9
9
|
type: 'deleted';
|
|
10
10
|
prev: Model[];
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type Listener<Model> = (action: Actions<Model>) => unknown;
|
|
13
13
|
export default class SubscribeStore<KeyPath extends keyof Model, KeyValue extends AllowedKeyValue, Model extends BaseModel & Record<KeyPath, KeyValue>, ModelInsertType extends InsertType<Model, KeyPath>, Connection extends AbstractConnection, Store extends SubscribableStore<KeyPath, KeyValue, Model, ModelInsertType, Connection>> implements StoreInterface<KeyPath, KeyValue, Model, ModelInsertType, Connection> {
|
|
14
14
|
private readonly store;
|
|
15
15
|
private readonly listeners;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscribeStore.d.ts","sourceRoot":"","sources":["../../src/SubscribeStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,IAAI,cAAc,EACvB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,OAAO,CAAC,KAAK,IACrB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,KAAK,EAAE,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,KAAK,EAAE,CAAA;CAAE,CAAC;AAEvC,MAAM,MAAM,QAAQ,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC;AAElE,MAAM,CAAC,OAAO,OAAO,cAAc,CACjC,OAAO,SAAS,MAAM,KAAK,EAC3B,QAAQ,SAAS,eAAe,EAChC,KAAK,SAAS,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnD,eAAe,SAAS,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,EAClD,UAAU,SAAS,kBAAkB,EACrC,KAAK,SAAS,iBAAiB,CAC7B,OAAO,EACP,QAAQ,E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E,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index-browser.es.js
CHANGED
|
@@ -10,46 +10,37 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
10
10
|
this.store = store;
|
|
11
11
|
this.keyPath = store.keyPath;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
var _proto = SubscribeStore.prototype;
|
|
15
|
-
|
|
16
14
|
_proto.subscribe = function subscribe(callback) {
|
|
17
15
|
this.listeners.add(callback);
|
|
18
16
|
return function () {
|
|
19
17
|
return this.listeners["delete"](callback);
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
_proto.callSubscribed = function callSubscribed(action) {
|
|
24
21
|
this.listeners.forEach(function (listener) {
|
|
25
22
|
return listener(action);
|
|
26
23
|
});
|
|
27
24
|
};
|
|
28
|
-
|
|
29
25
|
_proto.createQuerySingleItem = function createQuerySingleItem(options, transformer) {
|
|
30
26
|
var query = this.store.createQuerySingleItem(options, transformer);
|
|
31
27
|
query.setSubscribeStore(this);
|
|
32
28
|
return query;
|
|
33
29
|
};
|
|
34
|
-
|
|
35
30
|
_proto.createQueryCollection = function createQueryCollection(options, transformer) {
|
|
36
31
|
var query = this.store.createQueryCollection(options, transformer);
|
|
37
32
|
query.setSubscribeStore(this);
|
|
38
33
|
return query;
|
|
39
34
|
};
|
|
40
|
-
|
|
41
35
|
_proto.findAll = function findAll(criteria, sort) {
|
|
42
36
|
return this.store.findAll(criteria, sort);
|
|
43
37
|
};
|
|
44
|
-
|
|
45
38
|
_proto.findByKey = function findByKey(key, criteria) {
|
|
46
39
|
return this.store.findByKey(key, criteria);
|
|
47
40
|
};
|
|
48
|
-
|
|
49
41
|
_proto.findOne = function findOne(criteria, sort) {
|
|
50
42
|
return this.store.findOne(criteria, sort);
|
|
51
43
|
};
|
|
52
|
-
|
|
53
44
|
_proto.insertOne = /*#__PURE__*/function () {
|
|
54
45
|
var _insertOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(object) {
|
|
55
46
|
var inserted;
|
|
@@ -59,7 +50,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
59
50
|
case 0:
|
|
60
51
|
_context.next = 2;
|
|
61
52
|
return this.store.insertOne(object);
|
|
62
|
-
|
|
63
53
|
case 2:
|
|
64
54
|
inserted = _context.sent;
|
|
65
55
|
this.callSubscribed({
|
|
@@ -67,7 +57,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
67
57
|
next: [inserted]
|
|
68
58
|
});
|
|
69
59
|
return _context.abrupt("return", inserted);
|
|
70
|
-
|
|
71
60
|
case 5:
|
|
72
61
|
case "end":
|
|
73
62
|
return _context.stop();
|
|
@@ -75,12 +64,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
75
64
|
}
|
|
76
65
|
}, _callee, this);
|
|
77
66
|
}));
|
|
78
|
-
|
|
79
67
|
return function insertOne() {
|
|
80
68
|
return _insertOne.apply(this, arguments);
|
|
81
69
|
};
|
|
82
70
|
}();
|
|
83
|
-
|
|
84
71
|
_proto.replaceOne = /*#__PURE__*/function () {
|
|
85
72
|
var _replaceOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(object) {
|
|
86
73
|
var replaced;
|
|
@@ -90,7 +77,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
90
77
|
case 0:
|
|
91
78
|
_context2.next = 2;
|
|
92
79
|
return this.store.replaceOne(object);
|
|
93
|
-
|
|
94
80
|
case 2:
|
|
95
81
|
replaced = _context2.sent;
|
|
96
82
|
this.callSubscribed({
|
|
@@ -98,7 +84,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
98
84
|
changes: [[object, replaced]]
|
|
99
85
|
});
|
|
100
86
|
return _context2.abrupt("return", replaced);
|
|
101
|
-
|
|
102
87
|
case 5:
|
|
103
88
|
case "end":
|
|
104
89
|
return _context2.stop();
|
|
@@ -106,12 +91,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
106
91
|
}
|
|
107
92
|
}, _callee2, this);
|
|
108
93
|
}));
|
|
109
|
-
|
|
110
94
|
return function replaceOne() {
|
|
111
95
|
return _replaceOne.apply(this, arguments);
|
|
112
96
|
};
|
|
113
97
|
}();
|
|
114
|
-
|
|
115
98
|
_proto.replaceSeveral = /*#__PURE__*/function () {
|
|
116
99
|
var _replaceSeveral = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(objects) {
|
|
117
100
|
var replacedObjects;
|
|
@@ -121,7 +104,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
121
104
|
case 0:
|
|
122
105
|
_context3.next = 2;
|
|
123
106
|
return this.store.replaceSeveral(objects);
|
|
124
|
-
|
|
125
107
|
case 2:
|
|
126
108
|
replacedObjects = _context3.sent;
|
|
127
109
|
this.callSubscribed({
|
|
@@ -131,7 +113,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
131
113
|
})
|
|
132
114
|
});
|
|
133
115
|
return _context3.abrupt("return", replacedObjects);
|
|
134
|
-
|
|
135
116
|
case 5:
|
|
136
117
|
case "end":
|
|
137
118
|
return _context3.stop();
|
|
@@ -139,12 +120,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
139
120
|
}
|
|
140
121
|
}, _callee3, this);
|
|
141
122
|
}));
|
|
142
|
-
|
|
143
123
|
return function replaceSeveral() {
|
|
144
124
|
return _replaceSeveral.apply(this, arguments);
|
|
145
125
|
};
|
|
146
126
|
}();
|
|
147
|
-
|
|
148
127
|
_proto.upsertOne = /*#__PURE__*/function () {
|
|
149
128
|
var _upsertOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(object, setOnInsertPartialObject) {
|
|
150
129
|
var result;
|
|
@@ -154,11 +133,9 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
154
133
|
case 0:
|
|
155
134
|
_context4.next = 2;
|
|
156
135
|
return this.upsertOneWithInfo(object, setOnInsertPartialObject);
|
|
157
|
-
|
|
158
136
|
case 2:
|
|
159
137
|
result = _context4.sent;
|
|
160
138
|
return _context4.abrupt("return", result.object);
|
|
161
|
-
|
|
162
139
|
case 4:
|
|
163
140
|
case "end":
|
|
164
141
|
return _context4.stop();
|
|
@@ -166,12 +143,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
166
143
|
}
|
|
167
144
|
}, _callee4, this);
|
|
168
145
|
}));
|
|
169
|
-
|
|
170
146
|
return function upsertOne() {
|
|
171
147
|
return _upsertOne.apply(this, arguments);
|
|
172
148
|
};
|
|
173
149
|
}();
|
|
174
|
-
|
|
175
150
|
_proto.upsertOneWithInfo = /*#__PURE__*/function () {
|
|
176
151
|
var _upsertOneWithInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(object, setOnInsertPartialObject) {
|
|
177
152
|
var upsertedWithInfo;
|
|
@@ -181,28 +156,22 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
181
156
|
case 0:
|
|
182
157
|
_context5.next = 2;
|
|
183
158
|
return this.store.upsertOneWithInfo(object, setOnInsertPartialObject);
|
|
184
|
-
|
|
185
159
|
case 2:
|
|
186
160
|
upsertedWithInfo = _context5.sent;
|
|
187
|
-
|
|
188
161
|
if (!upsertedWithInfo.inserted) {
|
|
189
162
|
_context5.next = 7;
|
|
190
163
|
break;
|
|
191
164
|
}
|
|
192
|
-
|
|
193
165
|
this.callSubscribed({
|
|
194
166
|
type: 'inserted',
|
|
195
167
|
next: [upsertedWithInfo.object]
|
|
196
168
|
});
|
|
197
169
|
_context5.next = 8;
|
|
198
170
|
break;
|
|
199
|
-
|
|
200
171
|
case 7:
|
|
201
172
|
throw new Error('TODO');
|
|
202
|
-
|
|
203
173
|
case 8:
|
|
204
174
|
return _context5.abrupt("return", upsertedWithInfo);
|
|
205
|
-
|
|
206
175
|
case 9:
|
|
207
176
|
case "end":
|
|
208
177
|
return _context5.stop();
|
|
@@ -210,16 +179,13 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
210
179
|
}
|
|
211
180
|
}, _callee5, this);
|
|
212
181
|
}));
|
|
213
|
-
|
|
214
182
|
return function upsertOneWithInfo() {
|
|
215
183
|
return _upsertOneWithInfo.apply(this, arguments);
|
|
216
184
|
};
|
|
217
185
|
}();
|
|
218
|
-
|
|
219
186
|
_proto.partialUpdateByKey = /*#__PURE__*/function () {
|
|
220
187
|
var _partialUpdateByKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key, partialUpdate, criteria) {
|
|
221
188
|
var _extends2;
|
|
222
|
-
|
|
223
189
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
224
190
|
while (1) {
|
|
225
191
|
switch (_context6.prev = _context6.next) {
|
|
@@ -227,12 +193,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
227
193
|
_context6.t0 = this;
|
|
228
194
|
_context6.next = 3;
|
|
229
195
|
return this.findOne(_extends((_extends2 = {}, _extends2[this.store.keyPath] = key, _extends2), criteria));
|
|
230
|
-
|
|
231
196
|
case 3:
|
|
232
197
|
_context6.t1 = _context6.sent;
|
|
233
198
|
_context6.t2 = partialUpdate;
|
|
234
199
|
return _context6.abrupt("return", _context6.t0.partialUpdateOne.call(_context6.t0, _context6.t1, _context6.t2));
|
|
235
|
-
|
|
236
200
|
case 6:
|
|
237
201
|
case "end":
|
|
238
202
|
return _context6.stop();
|
|
@@ -240,12 +204,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
240
204
|
}
|
|
241
205
|
}, _callee6, this);
|
|
242
206
|
}));
|
|
243
|
-
|
|
244
207
|
return function partialUpdateByKey() {
|
|
245
208
|
return _partialUpdateByKey.apply(this, arguments);
|
|
246
209
|
};
|
|
247
210
|
}();
|
|
248
|
-
|
|
249
211
|
_proto.partialUpdateOne = /*#__PURE__*/function () {
|
|
250
212
|
var _partialUpdateOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(object, partialUpdate) {
|
|
251
213
|
var updated;
|
|
@@ -255,7 +217,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
255
217
|
case 0:
|
|
256
218
|
_context7.next = 2;
|
|
257
219
|
return this.store.partialUpdateOne(object, partialUpdate);
|
|
258
|
-
|
|
259
220
|
case 2:
|
|
260
221
|
updated = _context7.sent;
|
|
261
222
|
this.callSubscribed({
|
|
@@ -263,7 +224,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
263
224
|
changes: [[object, updated]]
|
|
264
225
|
});
|
|
265
226
|
return _context7.abrupt("return", updated);
|
|
266
|
-
|
|
267
227
|
case 5:
|
|
268
228
|
case "end":
|
|
269
229
|
return _context7.stop();
|
|
@@ -271,16 +231,13 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
271
231
|
}
|
|
272
232
|
}, _callee7, this);
|
|
273
233
|
}));
|
|
274
|
-
|
|
275
234
|
return function partialUpdateOne() {
|
|
276
235
|
return _partialUpdateOne.apply(this, arguments);
|
|
277
236
|
};
|
|
278
237
|
}();
|
|
279
|
-
|
|
280
238
|
_proto.partialUpdateMany = /*#__PURE__*/function () {
|
|
281
239
|
var _partialUpdateMany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(criteria, partialUpdate) {
|
|
282
240
|
var _this2 = this;
|
|
283
|
-
|
|
284
241
|
var cursor, changes;
|
|
285
242
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
286
243
|
while (1) {
|
|
@@ -288,7 +245,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
288
245
|
case 0:
|
|
289
246
|
_context9.next = 2;
|
|
290
247
|
return this.store.cursor(criteria);
|
|
291
|
-
|
|
292
248
|
case 2:
|
|
293
249
|
cursor = _context9.sent;
|
|
294
250
|
changes = [];
|
|
@@ -303,11 +259,9 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
303
259
|
key = model[_this2.store.keyPath];
|
|
304
260
|
_context8.next = 3;
|
|
305
261
|
return _this2.store.partialUpdateByKey(key, partialUpdate, criteria);
|
|
306
|
-
|
|
307
262
|
case 3:
|
|
308
263
|
updated = _context8.sent;
|
|
309
264
|
changes.push([model, updated]);
|
|
310
|
-
|
|
311
265
|
case 5:
|
|
312
266
|
case "end":
|
|
313
267
|
return _context8.stop();
|
|
@@ -315,18 +269,15 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
315
269
|
}
|
|
316
270
|
}, _callee8);
|
|
317
271
|
}));
|
|
318
|
-
|
|
319
272
|
return function () {
|
|
320
273
|
return _ref.apply(this, arguments);
|
|
321
274
|
};
|
|
322
275
|
}());
|
|
323
|
-
|
|
324
276
|
case 6:
|
|
325
277
|
this.callSubscribed({
|
|
326
278
|
type: 'updated',
|
|
327
279
|
changes: changes
|
|
328
280
|
});
|
|
329
|
-
|
|
330
281
|
case 7:
|
|
331
282
|
case "end":
|
|
332
283
|
return _context9.stop();
|
|
@@ -334,12 +285,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
334
285
|
}
|
|
335
286
|
}, _callee9, this);
|
|
336
287
|
}));
|
|
337
|
-
|
|
338
288
|
return function partialUpdateMany() {
|
|
339
289
|
return _partialUpdateMany.apply(this, arguments);
|
|
340
290
|
};
|
|
341
291
|
}();
|
|
342
|
-
|
|
343
292
|
_proto.deleteByKey = /*#__PURE__*/function () {
|
|
344
293
|
var _deleteByKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, criteria) {
|
|
345
294
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
@@ -349,11 +298,9 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
349
298
|
_context10.t0 = this;
|
|
350
299
|
_context10.next = 3;
|
|
351
300
|
return this.findByKey(key, criteria);
|
|
352
|
-
|
|
353
301
|
case 3:
|
|
354
302
|
_context10.t1 = _context10.sent;
|
|
355
303
|
return _context10.abrupt("return", _context10.t0.deleteOne.call(_context10.t0, _context10.t1));
|
|
356
|
-
|
|
357
304
|
case 5:
|
|
358
305
|
case "end":
|
|
359
306
|
return _context10.stop();
|
|
@@ -361,12 +308,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
361
308
|
}
|
|
362
309
|
}, _callee10, this);
|
|
363
310
|
}));
|
|
364
|
-
|
|
365
311
|
return function deleteByKey() {
|
|
366
312
|
return _deleteByKey.apply(this, arguments);
|
|
367
313
|
};
|
|
368
314
|
}();
|
|
369
|
-
|
|
370
315
|
_proto.deleteOne = /*#__PURE__*/function () {
|
|
371
316
|
var _deleteOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(object) {
|
|
372
317
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
@@ -375,13 +320,11 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
375
320
|
case 0:
|
|
376
321
|
_context11.next = 2;
|
|
377
322
|
return this.store.deleteOne(object);
|
|
378
|
-
|
|
379
323
|
case 2:
|
|
380
324
|
this.callSubscribed({
|
|
381
325
|
type: 'deleted',
|
|
382
326
|
prev: [object]
|
|
383
327
|
});
|
|
384
|
-
|
|
385
328
|
case 3:
|
|
386
329
|
case "end":
|
|
387
330
|
return _context11.stop();
|
|
@@ -389,12 +332,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
389
332
|
}
|
|
390
333
|
}, _callee11, this);
|
|
391
334
|
}));
|
|
392
|
-
|
|
393
335
|
return function deleteOne() {
|
|
394
336
|
return _deleteOne.apply(this, arguments);
|
|
395
337
|
};
|
|
396
338
|
}();
|
|
397
|
-
|
|
398
339
|
_proto.deleteMany = /*#__PURE__*/function () {
|
|
399
340
|
var _deleteMany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(criteria) {
|
|
400
341
|
var cursor, prev;
|
|
@@ -404,23 +345,19 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
404
345
|
case 0:
|
|
405
346
|
_context12.next = 2;
|
|
406
347
|
return this.store.cursor(criteria);
|
|
407
|
-
|
|
408
348
|
case 2:
|
|
409
349
|
cursor = _context12.sent;
|
|
410
350
|
_context12.next = 5;
|
|
411
351
|
return cursor.toArray();
|
|
412
|
-
|
|
413
352
|
case 5:
|
|
414
353
|
prev = _context12.sent;
|
|
415
354
|
_context12.next = 8;
|
|
416
355
|
return this.store.deleteMany(criteria);
|
|
417
|
-
|
|
418
356
|
case 8:
|
|
419
357
|
this.callSubscribed({
|
|
420
358
|
type: 'deleted',
|
|
421
359
|
prev: prev
|
|
422
360
|
});
|
|
423
|
-
|
|
424
361
|
case 9:
|
|
425
362
|
case "end":
|
|
426
363
|
return _context12.stop();
|
|
@@ -428,12 +365,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
428
365
|
}
|
|
429
366
|
}, _callee12, this);
|
|
430
367
|
}));
|
|
431
|
-
|
|
432
368
|
return function deleteMany() {
|
|
433
369
|
return _deleteMany.apply(this, arguments);
|
|
434
370
|
};
|
|
435
371
|
}();
|
|
436
|
-
|
|
437
372
|
_proto.count = /*#__PURE__*/function () {
|
|
438
373
|
var _count = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(criteria) {
|
|
439
374
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
@@ -441,7 +376,6 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
441
376
|
switch (_context13.prev = _context13.next) {
|
|
442
377
|
case 0:
|
|
443
378
|
return _context13.abrupt("return", this.store.count(criteria));
|
|
444
|
-
|
|
445
379
|
case 1:
|
|
446
380
|
case "end":
|
|
447
381
|
return _context13.stop();
|
|
@@ -449,12 +383,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
449
383
|
}
|
|
450
384
|
}, _callee13, this);
|
|
451
385
|
}));
|
|
452
|
-
|
|
453
386
|
return function count() {
|
|
454
387
|
return _count.apply(this, arguments);
|
|
455
388
|
};
|
|
456
389
|
}();
|
|
457
|
-
|
|
458
390
|
_proto.cursor = /*#__PURE__*/function () {
|
|
459
391
|
var _cursor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(criteria, sort) {
|
|
460
392
|
var cursor;
|
|
@@ -464,12 +396,10 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
464
396
|
case 0:
|
|
465
397
|
_context14.next = 2;
|
|
466
398
|
return this.store.cursor(criteria, sort);
|
|
467
|
-
|
|
468
399
|
case 2:
|
|
469
400
|
cursor = _context14.sent;
|
|
470
401
|
cursor.overrideStore(this);
|
|
471
402
|
return _context14.abrupt("return", cursor);
|
|
472
|
-
|
|
473
403
|
case 5:
|
|
474
404
|
case "end":
|
|
475
405
|
return _context14.stop();
|
|
@@ -477,55 +407,43 @@ var SubscribeStore = /*#__PURE__*/function () {
|
|
|
477
407
|
}
|
|
478
408
|
}, _callee14, this);
|
|
479
409
|
}));
|
|
480
|
-
|
|
481
410
|
return function cursor() {
|
|
482
411
|
return _cursor.apply(this, arguments);
|
|
483
412
|
};
|
|
484
413
|
}();
|
|
485
|
-
|
|
486
414
|
_createClass(SubscribeStore, [{
|
|
487
415
|
key: "connection",
|
|
488
416
|
get: function get() {
|
|
489
417
|
return this.store.connection;
|
|
490
418
|
}
|
|
491
419
|
}]);
|
|
492
|
-
|
|
493
420
|
return SubscribeStore;
|
|
494
421
|
}();
|
|
495
422
|
|
|
496
423
|
var AbstractSubscribableStoreQuery = /*#__PURE__*/function () {
|
|
497
424
|
function AbstractSubscribableStoreQuery() {}
|
|
498
|
-
|
|
499
425
|
var _proto = AbstractSubscribableStoreQuery.prototype;
|
|
500
|
-
|
|
501
426
|
_proto.changeParams = function changeParams() {
|
|
502
427
|
throw new Error('Method not supported. Please create a new query.');
|
|
503
428
|
};
|
|
504
|
-
|
|
505
429
|
_proto.changePartialParams = function changePartialParams() {
|
|
506
430
|
throw new Error('Method not supported. Please create a new query.');
|
|
507
431
|
};
|
|
508
|
-
|
|
509
432
|
_proto.setSubscribeStore = function setSubscribeStore(store) {
|
|
510
433
|
this._subscribeStore = store;
|
|
511
434
|
};
|
|
512
|
-
|
|
513
435
|
_proto.getSubscribeStore = function getSubscribeStore() {
|
|
514
436
|
if (!this._subscribeStore) {
|
|
515
437
|
throw new Error('_subscribeStore is not initialized');
|
|
516
438
|
}
|
|
517
|
-
|
|
518
439
|
return this._subscribeStore;
|
|
519
440
|
};
|
|
520
|
-
|
|
521
441
|
_proto.fetchAndSubscribe = function fetchAndSubscribe(callback) {
|
|
522
442
|
return this._subscribe(callback, true);
|
|
523
443
|
};
|
|
524
|
-
|
|
525
444
|
_proto.subscribe = function subscribe(callback) {
|
|
526
445
|
return this._subscribe(callback, false);
|
|
527
446
|
};
|
|
528
|
-
|
|
529
447
|
return AbstractSubscribableStoreQuery;
|
|
530
448
|
}();
|
|
531
449
|
|