@depup/mongoose 9.1.3-depup.0 → 9.1.4-depup.0
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.
|
@@ -599,6 +599,9 @@ function _nextDoc(ctx, doc, pop, callback) {
|
|
|
599
599
|
if (err != null) {
|
|
600
600
|
return callback(err);
|
|
601
601
|
}
|
|
602
|
+
if (options.session != null) {
|
|
603
|
+
doc.$session(options.session);
|
|
604
|
+
}
|
|
602
605
|
ctx.model.hooks.execPost('find', ctx.query, [[doc]]).then(() => callback(null, doc), err => callback(err));
|
|
603
606
|
});
|
|
604
607
|
}
|
package/lib/helpers/clone.js
CHANGED
|
@@ -51,11 +51,20 @@ function clone(obj, options, isArrayChild) {
|
|
|
51
51
|
clonedDoc.__index = obj.__index;
|
|
52
52
|
}
|
|
53
53
|
if (obj.__parentArray != null) {
|
|
54
|
-
clonedDoc.__parentArray = obj.__parentArray;
|
|
54
|
+
clonedDoc.__parentArray = options.parentArray ?? obj.__parentArray;
|
|
55
55
|
}
|
|
56
56
|
clonedDoc.$__setParent(options.parentDoc ?? obj.$__parent);
|
|
57
57
|
return clonedDoc;
|
|
58
58
|
}
|
|
59
|
+
if (options.retainDocuments && obj.$isMongooseMap) {
|
|
60
|
+
const clonedParent = options.parentDoc ?? obj.$__parent;
|
|
61
|
+
const MongooseMap = obj.constructor;
|
|
62
|
+
const ret = new MongooseMap({}, obj.$__path, clonedParent, obj.$__schemaType);
|
|
63
|
+
for (const [key, value] of obj) {
|
|
64
|
+
ret.$__set(key, clone(value, options));
|
|
65
|
+
}
|
|
66
|
+
return ret;
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
if (isPOJO(obj) && obj.$__ != null && obj._doc != null) {
|
|
@@ -187,6 +196,11 @@ function cloneArray(arr, options) {
|
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
arr = isMongooseArray(arr) ? arr.__array : arr;
|
|
199
|
+
if (ret.isMongooseDocumentArray) {
|
|
200
|
+
// Create new options object to avoid mutating the shared options.
|
|
201
|
+
// Subdocs need parentArray to point to their own cloned array.
|
|
202
|
+
options = { ...options, parentArray: ret };
|
|
203
|
+
}
|
|
190
204
|
for (i = 0; i < len; ++i) {
|
|
191
205
|
ret[i] = clone(arr[i], options, true);
|
|
192
206
|
}
|
package/lib/schema/array.js
CHANGED
|
@@ -398,6 +398,9 @@ SchemaArray.prototype.cast = function(value, doc, init, prev, options) {
|
|
|
398
398
|
if (options.hydratedPopulatedDocs) {
|
|
399
399
|
opts.hydratedPopulatedDocs = options.hydratedPopulatedDocs;
|
|
400
400
|
}
|
|
401
|
+
if (options.virtuals) {
|
|
402
|
+
opts.virtuals = options.virtuals;
|
|
403
|
+
}
|
|
401
404
|
rawValue[i] = caster.applySetters(rawValue[i], doc, init, void 0, opts);
|
|
402
405
|
}
|
|
403
406
|
} catch (e) {
|