@routier/core 0.0.2 → 0.0.3
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/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.js +10 -2
- package/dist/plugins/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5390,6 +5390,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
5390
5390
|
const sourcePlugin = this.plugins.source;
|
|
5391
5391
|
const collectionSize = getMemoryPluginCollectionSize(this.plugins.read, event.operation.schema);
|
|
5392
5392
|
if (collectionSize === 0 && cache.has(WAS_OPTIMISTIC_DB_HYDRATED_KEY) === false) {
|
|
5393
|
+
// Notify the cache that the db was hydrated right away
|
|
5394
|
+
cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5393
5395
|
// nothing is hydrated, let's try and hydrate before querying
|
|
5394
5396
|
// Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
|
|
5395
5397
|
// Other queries will do the same and hydrate if needed
|
|
@@ -5402,14 +5404,20 @@ class OptimisticReplicationDbPlugin {
|
|
|
5402
5404
|
operation: _query__WEBPACK_IMPORTED_MODULE_1__.Query.EMPTY(event.operation.schema)
|
|
5403
5405
|
}, (sourceResult) => {
|
|
5404
5406
|
if (sourceResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
5407
|
+
// Notify that hydration failed
|
|
5408
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5405
5409
|
done(sourceResult);
|
|
5406
5410
|
return;
|
|
5407
5411
|
}
|
|
5408
5412
|
if (sourceResult == null || (Array.isArray(sourceResult.data) && sourceResult.data.length === 0)) {
|
|
5413
|
+
// Notify that hydration had no data
|
|
5414
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5409
5415
|
done(sourceResult);
|
|
5410
5416
|
return;
|
|
5411
5417
|
}
|
|
5412
5418
|
if (Array.isArray(sourceResult.data) === false) {
|
|
5419
|
+
// Notify that hydration failed
|
|
5420
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5413
5421
|
done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Query result is not an array"));
|
|
5414
5422
|
return;
|
|
5415
5423
|
}
|
|
@@ -5424,11 +5432,11 @@ class OptimisticReplicationDbPlugin {
|
|
|
5424
5432
|
source: "collection",
|
|
5425
5433
|
}, (readPersistResult) => {
|
|
5426
5434
|
if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
5435
|
+
// Notify that hydration failed
|
|
5436
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5427
5437
|
done(readPersistResult);
|
|
5428
5438
|
return;
|
|
5429
5439
|
}
|
|
5430
|
-
// Notify the cache that the db was hydrated
|
|
5431
|
-
cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5432
5440
|
// requery the read plugin
|
|
5433
5441
|
readPlugin.query(event, done);
|
|
5434
5442
|
});
|