Skip to content

Commit

Permalink
refactor: rename to $__toObjectShallow() based on code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 10, 2024
1 parent 9dc2e8a commit 8223f91
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -3866,7 +3866,7 @@ Document.prototype.$toObject = function(options, json) {
if (hasOnlyPrimitiveValues && !options.flattenObjectIds) {
// Fast path: if we don't have any nested objects or arrays, we only need a
// shallow clone.
ret = this.$__toObjectInternal();
ret = this.$__toObjectShallow();
} else {
ret = clone(this._doc, options) || {};
}
Expand Down Expand Up @@ -3931,7 +3931,7 @@ Document.prototype.$toObject = function(options, json) {
* Internal shallow clone alternative to `$toObject()`: much faster, no options processing
*/

Document.prototype.$__toObjectInternal = function $__toObjectInternal() {
Document.prototype.$__toObjectShallow = function $__toObjectShallow() {
const ret = {};
if (this._doc != null) {
for (const key of Object.keys(this._doc)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2954,7 +2954,7 @@ Model.$__insertMany = function(arr, options, callback) {
doc.initializeTimestamps();
}
if (doc.$__hasOnlyPrimitiveValues()) {
return doc.$__toObjectInternal();
return doc.$__toObjectShallow();
}
return doc.toObject(internalToObjectOptions);
});
Expand Down

0 comments on commit 8223f91

Please sign in to comment.