You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since clone has some dependencies from utils, also:
- specialProperties to helpers/specialProperties;
- isMongooseObject to helpers/isMongooseObject;
- getFunctionName to helpers/getFunctionName;
- isBsonType to helpers/isBsonType;
- isObject to helpers/isObject.
I'd resisted to temptation to refactor methods, with two exception:
- util.object.vals changed by Object.values;
- utils.each changed forEach.
Updated reference from utils to helpers at:
- lib/browserDocument.js;
- lib/cast.js;
- lib/drivers/node-mongodb-native/collection.js;
- lib/helpers/common.js;
- lib/helpers/schema/getIndexes.js;
- lib/options/PopulateOptions.js;
- lib/options/SchemaTypeOptions.js;
- lib/options/removeOptions.js;
- lib/options/saveOptions.js;
- lib/queryhelpers.js;
- lib/schema/mixed.js;
- lib/types/map.js.
* If options.minimize is true, creates a minimal data object. Empty objects and undefined values will not be cloned. This makes the data payload sent to MongoDB as small as possible.
19
+
*
20
+
* Functions are never cloned.
21
+
*
22
+
* @param {Object} obj the object to clone
23
+
* @param {Object} options
24
+
* @param {Boolean} isArrayChild true if cloning immediately underneath an array. Special case for minimize.
25
+
* @return {Object} the cloned object
26
+
* @api private
27
+
*/
28
+
29
+
functionclone(obj,options,isArrayChild){
30
+
if(obj==null){
31
+
returnobj;
32
+
}
33
+
34
+
if(Array.isArray(obj)){
35
+
returncloneArray(obj,options);
36
+
}
37
+
38
+
if(isMongooseObject(obj)){
39
+
// Single nested subdocs should apply getters later in `applyGetters()`
40
+
// when calling `toObject()`. See gh-7442, gh-8295
0 commit comments