MongoEngine / MongoEngine/mongoengine

Adding Enum Field and to_dict functionality

Open
#2,347 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Hello everyone.
We have found ourselves (Cuenca), using and reusing several functionalities in some of our projects, which are, at the moment, not implemented in this project. For this reason we created a python file where we implement this functionalities, but since we use them in different projects we have been copying and pasting this file.

We would like to add some of this functionalities to this repository for everyone to use, such as an Enum field (present in this repository) and a to_dict functionality inside the BaseDocument class.

In this file you can see how we are currently creating the Enum field, and in this one, you can see how we are implementing it.

Here you can also see how we are using the to_dict functionality. This functionality is self explanatory since it just returns the fields of a model turned into a dictionary to work with. You can see an example on how we are using it, right here, inheriting the BaseModel class we created to add the functionality to all our Models. You can see how we are using this in here.

We would love to have your feedback on this, and also hear your thoughts on this subject, and to know wether it is possible or not to implement this changes. Thanks a lot in advance

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the repository’s BaseDocument API and field implementations, then compare the linked examples in speid/models/helpers.py, speid/models/transaction.py, and speid/models/base.py. Clarify enum and serialization behavior before adding focused tests; done means both APIs have agreed behavior and regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.