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.
- package/lib/AbstractApiModule.js +5 -1
- package/package.json +1 -1
package/lib/AbstractApiModule.js
CHANGED
|
@@ -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)
|
|
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)))
|