推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
tangkikodo
V2EX  ›  Python

异步构建嵌套数据的小工具库: pydantic-resolve

  •  1
     
  •   tangkikodo · Jun 10, 2023 · 2156 views
    This topic created in 1206 days ago, the information mentioned may be changed or developed.

    之前来 V2EX 有小小安利过,https://www.v2ex.com/t/928991

    后来根据使用反馈后续做了改进。也进一步完善了文档和介绍。

    所以重新来安利一下:

    https://pydantic-resolve.readthedocs.io/en/latest/

    https://github.com/allmonday/pydantic-resolve

    这个小工具库可以方便的构建 graphql 那样的多层级数据,同时内部对 dataloader 做了一些初始化管理,消灭了 loader 需要在 middleware 层初始化的烦恼。

    一些场景:

    • 模仿 grapql ,在后端拼接出一个页面所需的全部数据 (当然,木有 gql 这么动态灵活, 但接口更稳定容易维护)
    • 轻松拼接各种关系表数据
    • 解决嵌套数据中 N+1 查询问题

    如果有类似烦恼的话,可以拿来试试。

    如果是 fastapi 用户,配合 response_model + openapi-typescript-generator 食用更佳。

    已经在生产环境稳定使用。并积极维护中。

    欢迎尝鲜。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   891 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 19:47 · PVG 03:47 · LAX 12:47 · JFK 15:47
    ♥ Do have faith in what you're doing.