MongoEngine / MongoEngine/mongoengine
Possibility of embedding a clone of a document as embedded
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
My current issue arises from the need of snapshotting documents for later use.
Say I have a
class User(Document):
name = StringField()
and a
class Message(Document):
message = StringField()
user = DynamicField()
For every message that the user sends I'd like to save a copy of the user in case the user changes his name, I'd see what the user looked like when he sent the message.
The example might not make any sense but the idea should be clear. Previously (I think < 0.10) I could create a Document by inheriting both Document and EmbeddedDocument, but for some reason that is not possible any more.
How could I implement snapshotting of Documents as EmbeddedDocuments, or if not elegantly possible, it would be a nice feature. I think making multiple inheritance from Document and EmbeddedDocument would be best.
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
Start by reviewing how Document and EmbeddedDocument are defined and how DynamicField stores referenced values. Compare the current inheritance constraints with the requested snapshotting use case, then identify the tests covering document inheritance and embedded documents. Done means the supported behavior and its limitations are documented and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100