nayan32biswas / mongodb-odm

MongoDB-ODM, NOSQL databases in Python, designed for simplicity, compatibility, and robustness.
https://mongodb-odm.readthedocs.io
MIT License
18 stars 1 forks source link

Support Set types #29

Open ansenlong opened 4 months ago

ansenlong commented 4 months ago

When my model has it need to convert my tags to a list before it tries to insert/update it to MongoDB.

class Video(Document): tags: Set[str]

I have a workaround with "field_serializer" but it would be nice if it could support sets out of the box.

nayan32biswas commented 4 months ago

Hi @ansenlong, Once I have tried it to provide support for the Set. But if we add that support we need to check each of the field types before inserting and updating which will degrade the performance of the ODM.

Also, MongoDB does not support Set out of the box. It would be better to add a save and update method for that specific model to do some pre-validation.

Other than that, you are very welcome to come up with a great solution. I will appreciate your contribution.