|
| 1 | +# Database model and fields definition |
| 2 | + |
| 3 | +```{important} |
| 4 | +Flask-Mongoengine does not adjust database level behaviour of [mongoengine] fields |
| 5 | +definition, except [keyword only definition] requirement. Everything other on |
| 6 | +database level match [mongoengine] project. All parent methods, arguments (as |
| 7 | +keyword arguments) and keyword arguments are supported. |
| 8 | +
|
| 9 | +If you are not intend to use WTForms integration, you are free to use fields classes |
| 10 | +from parent [mongoengine] project; this should not break anything. |
| 11 | +``` |
| 12 | + |
| 13 | +## Supported fields |
| 14 | + |
| 15 | +Flask-Mongoengine support all **database** fields definition. Even if there will be some |
| 16 | +new field type created in parent [mongoengine] project, we will silently bypass |
| 17 | +field definition to it, if we do not declare rules on our side. |
| 18 | + |
| 19 | +```{note} |
| 20 | +Version **2.0.0** Flask-Mongoengine update support [mongoengine] fields, based on |
| 21 | +version **mongoengine==0.21**. Any new fields bypassed without modification. |
| 22 | +``` |
| 23 | + |
| 24 | +## Keyword only definition |
| 25 | + |
| 26 | +```{eval-rst} |
| 27 | +.. versionchanged:: 2.0.0 |
| 28 | +``` |
| 29 | + |
| 30 | +Database model definition rules and Flask-WTF/WTForms [integration] was seriously |
| 31 | +updated in version **2.0.0**. Unfortunately, these changes implemented without any |
| 32 | +deprecation stages. |
| 33 | + |
| 34 | +Before version **2.0.0** Flask-Mongoengine integration allowed to pass fields |
| 35 | +parameters as arguments. To exclude any side effects or keyword parameters |
| 36 | +duplication/conflicts, since version **2.0.0** all fields require keyword |
| 37 | +only setup. |
| 38 | + |
| 39 | +Such approach removes number of issues and questions, when users frequently used |
| 40 | +Flask-WTF/WTForms definition rules by mistake, or just missed that some arguments |
| 41 | +was passed to keyword places silently creating unexpected side effects. You can |
| 42 | +check issue [#379] as example of one of such cases. |
| 43 | + |
| 44 | +[mongoengine]: https://docs.mongoengine.org/ |
| 45 | +[#379]: https://github.com/MongoEngine/flask-mongoengine/issues/379 |
| 46 | +[integration]: forms |
| 47 | +[keyword only definition]: #keyword-only-definition |
0 commit comments