MongoEngine / MongoEngine/mongoengine
How to duplicate a document
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
Hi Im having problem duplicating a document, which is I needed the most.
I already tried using deepcopy but it is not working as expected,
z=deepcopy(x)
z.container_type=RootModel.Item.QOUTATION
z.qoutation=q
z.save()
Now what just happened is it only insert the field which I personally change so the result became like this
{ "_id" : 22, "container_type" : "QOUTATION", "qoutation" : 14 }
It should have other information. Does deepcopy works well on this method?
But printing the copied data prints all the information, I just don't know why it is not saving the rest of information..
Sinse to_mongo returns the real data, is there a way to make this document inserted? like to_mongo().save()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is identified. Start by reproducing the deepcopy and save behavior from the example, then inspect the document save and to_mongo entry points. Done means establishing whether duplicated documents preserve unchanged fields and documenting or testing the expected insertion behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100