Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document.prototype.$clone() #11849

Closed
2 tasks done
vkarpov15 opened this issue May 29, 2022 · 0 comments 路 Fixed by #12549
Closed
2 tasks done

Document.prototype.$clone() #11849

vkarpov15 opened this issue May 29, 2022 · 0 comments 路 Fixed by #12549
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

馃殌 Feature Proposal

doc.$clone() should return a copy of doc with:

  1. Deep clone of _doc
  2. Deep clone of $__

So return a new doc with the same state (same isNew, populated state, change tracking state, etc.)

Motivation

This has popped up a couple of times in user questions, for example: #10788 . This has also popped up in internal work. Most recently, in #11442 $clone() would have been helpful because we could just create a clone of the document to handle that particular manually populated edge case, so we can ensure that we don't overwrite the document's existing $__.wasPopulated.

Example

No response

@vkarpov15 vkarpov15 added new feature This change adds new functionality, like a new method or class enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature labels May 29, 2022
@vkarpov15 vkarpov15 added this to the 6.x Unprioritized milestone May 29, 2022
lpizzinidev added a commit to lpizzinidev/mongoose that referenced this issue Oct 13, 2022
lpizzinidev added a commit to lpizzinidev/mongoose that referenced this issue Oct 19, 2022
@vkarpov15 vkarpov15 modified the milestones: 6.x Unprioritized, 6.8 Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant