@autofleet/matmon 2.0.0-beta-41 → 2.0.0-beta-43
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.
|
@@ -17,7 +17,7 @@ const util_1 = require("util");
|
|
|
17
17
|
const { AF_SERVICE_NAME } = process.env;
|
|
18
18
|
const INVALIDATION_HOOKS = ['afterSave', 'afterUpdate', 'afterDestroy'];
|
|
19
19
|
const BULK_HOOKS = ['beforeBulkUpdate', 'beforeBulkDestroy'];
|
|
20
|
-
const generateInstanceKey = (modelOptions,
|
|
20
|
+
const generateInstanceKey = (modelOptions, id) => `${AF_SERVICE_NAME}:${modelOptions.name}_${id}_INCLUDING_${modelOptions.associations.map(a => a.name).join('_')}`;
|
|
21
21
|
const generateDependencyKey = (modelName, associationName, associationId) => `${AF_SERVICE_NAME}:${modelName}_${associationName}_${associationId}_DEPENDENCIES`;
|
|
22
22
|
const handleTransactionHook = (instance, options, func) => {
|
|
23
23
|
const { transaction } = options;
|
|
@@ -92,6 +92,9 @@ class SequelizeAdapter {
|
|
|
92
92
|
const removeMultiAsync = util_1.promisify(removeMulti.exec).bind(removeMulti);
|
|
93
93
|
const dependenciesToRemove = yield Promise.all(dependentInstancesKeys.map((instanceKey) => __awaiter(this, void 0, void 0, function* () {
|
|
94
94
|
const instance = JSON.parse(yield cache.getClient().getAsync(instanceKey));
|
|
95
|
+
if (!instance) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
95
98
|
const dependencyKeys = modelOptions.associations
|
|
96
99
|
.filter(association => instance[association.alias])
|
|
97
100
|
.map(association => generateDependencyKey(modelName, association.name, instance[association.alias].id));
|