@autofleet/matmon 2.0.0-beta-46 → 2.0.0-beta-47
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.
|
@@ -111,9 +111,7 @@ class SequelizeAdapter {
|
|
|
111
111
|
if (!instance) {
|
|
112
112
|
return [];
|
|
113
113
|
}
|
|
114
|
-
const dependencyKeys = modelOptions
|
|
115
|
-
.filter(association => instance[association.alias])
|
|
116
|
-
.map(association => generateDependencyKey(modelOptions.name, association.name, instance[association.alias].id));
|
|
114
|
+
const dependencyKeys = getInstanceDependencyKeys(modelOptions, instance);
|
|
117
115
|
dependencyKeys.reduce((multi, key) => multi.srem(key, instanceKey), removeMulti);
|
|
118
116
|
removeMulti.del(instanceKey);
|
|
119
117
|
return dependencyKeys;
|
|
@@ -124,9 +122,9 @@ class SequelizeAdapter {
|
|
|
124
122
|
const model = this.getModel(modelOptions.name);
|
|
125
123
|
INVALIDATION_HOOKS.map(hook => model.addHook(hook, (instance, options) => handleTransactionHook(instance, options, instance => invalidateModelInstance(instance))));
|
|
126
124
|
BULK_HOOKS.map(hook => model.addHook(hook, options => options.individualHook = true));
|
|
127
|
-
modelOptions.associations.map(
|
|
128
|
-
const associationModel = this.getModel(
|
|
129
|
-
INVALIDATION_HOOKS.map(hook => associationModel.addHook(hook, (instance, options) => handleTransactionHook(instance, options,
|
|
125
|
+
modelOptions.associations.map((associationOptions) => {
|
|
126
|
+
const associationModel = this.getModel(associationOptions.name);
|
|
127
|
+
INVALIDATION_HOOKS.map(hook => associationModel.addHook(hook, (instance, options) => handleTransactionHook(instance, options, associationInstance => invalidateModelInstanceByAssociation(associationOptions.name, associationInstance[associationOptions.accessKey || 'id']))));
|
|
130
128
|
BULK_HOOKS.map(hook => associationModel.addHook(hook, options => options.individualHook = true));
|
|
131
129
|
});
|
|
132
130
|
}
|