adapt-authoring-content 2.1.7 → 2.1.8
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/ContentModule.js +10 -3
- package/package.json +1 -1
package/lib/ContentModule.js
CHANGED
|
@@ -150,9 +150,16 @@ class ContentModule extends AbstractApiModule {
|
|
|
150
150
|
}
|
|
151
151
|
const descendants = await getDescendants(q => this.find(q), targetDoc)
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
// bulk-delete descendants directly to avoid per-item memory overhead and hook storms
|
|
154
|
+
if (descendants.length > 0) {
|
|
155
|
+
const mongodb = await this.app.waitForModule('mongodb')
|
|
156
|
+
await mongodb.deleteMany(this.collectionName, { _id: { $in: descendants.map(d => d._id) } }, mongoOptions)
|
|
157
|
+
}
|
|
158
|
+
// delete target via super.delete to trigger deleteHook middleware (e.g. multilang)
|
|
159
|
+
await super.delete({ _id: targetDoc._id }, options, mongoOptions)
|
|
160
|
+
if (descendants.length > 0 && options.invokePostHook !== false) {
|
|
161
|
+
await this.postDeleteHook.invoke(descendants)
|
|
162
|
+
}
|
|
156
163
|
await Promise.all([
|
|
157
164
|
this.updateEnabledPlugins(targetDoc, {}, options, mongoOptions),
|
|
158
165
|
this.updateSortOrder(targetDoc, undefined, options, mongoOptions)
|