art049 / odmantic

Sync and Async ODM (Object Document Mapper) for MongoDB based on python type hints

Home Page:http://art049.github.io/odmantic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

怎么排序

f754699 opened this issue · comments

Bug

我想根据前端传递的字符串进行排序,结果文档里只能使用模型的字段进行排序。
我想用Model[key]的方式获取字段,结果报错:"type 'DictType' is not subscriptable"

orderObject.order = “createTime”
sort=DictType[orderObject.order]
"type 'DictType' is not subscriptable"

Current Behavior

... Steps to reproduce the bug ...

Expected behavior

... A clear and concise description of what you expected to happen. ...

Environment

  • ODMantic version: ...
  • MongoDB version: ...
  • Pydantic infos (output of python -c "import pydantic.utils; print(pydantic.utils.version_info())):
...
  • Version of additional modules (if relevant):
    • ...

Additional context

Add any other context about the problem here.

没事了,可以传递元组