@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.associations
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(association => {
128
- const associationModel = this.getModel(association.name);
129
- INVALIDATION_HOOKS.map(hook => associationModel.addHook(hook, (instance, options) => handleTransactionHook(instance, options, ({ id }) => invalidateModelInstanceByAssociation(association.name, id))));
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/matmon",
3
- "version": "2.0.0-beta-46",
3
+ "version": "2.0.0-beta-47",
4
4
  "description": "manage cache",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",