adapt-authoring-api 3.2.2 → 3.2.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.
@@ -726,7 +726,9 @@ class AbstractApiModule extends AbstractModule {
726
726
 
727
727
  const updatedDocs = await mongodb.updateMany(options.collectionName, query, formattedData, mongoOptions)
728
728
 
729
- if (options.invokePostHook !== false) await Promise.all(updatedDocs.map(d => this.postUpdateHook.invoke(d, updatedDocs)))
729
+ if (options.invokePostHook !== false) {
730
+ await Promise.all(originalDocs.map((original, i) => this.postUpdateHook.invoke(original, updatedDocs[i])))
731
+ }
730
732
  return updatedDocs
731
733
  }
732
734
 
@@ -770,6 +772,8 @@ class AbstractApiModule extends AbstractModule {
770
772
 
771
773
  const mongodb = await this.app.waitForModule('mongodb')
772
774
  const toDelete = await mongodb.find(options.collectionName, query)
775
+
776
+ if (options.invokePreHook !== false) await Promise.all(toDelete.map(d => this.preDeleteHook.invoke(d, options, mongoOptions)))
773
777
  await mongodb.deleteMany(options.collectionName, query, mongoOptions)
774
778
 
775
779
  if (options.invokePostHook !== false) await Promise.all(toDelete.map(d => this.postDeleteHook.invoke(d)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-api",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
4
4
  "description": "Abstract module for creating APIs",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-api",
6
6
  "license": "GPL-3.0",