Git Product home page Git Product logo

Comments (3)

TommyLemon avatar TommyLemon commented on April 29, 2024

目前APIJSON没提供case功能,还没有比较好的方式在APIJSON自动化API里做。
建议用手写SQL语句的方式,或者MyBatis这种ORM库写XML代码。

APIJSON做了以下SQL查询优化:
1.字段限制(可选)
"@column": "id,name" //只查id和name两个字段,不多不少

2.查询缓存:
例如在查询某个用户User的动态Moment列表的一次请求中

{
    "[]": {
        "count": 5,
        "Moment": {
            "@order": "date-"
        },
        "User": {
            "id@": "/Moment/userId"
        }
    }
}

相同id的User只会去数据库查一次,之后都是调缓存。

3.查询预判
1)如果同时查 数据 和 数量 (可在[]对象中加query:2实现),当total <= count*page则不继续查数据库。
2)id和id{}都存在时判断id{}是否包含id,如果不包含则不去查数据库,直接返回空。

from apijson.

TommyLemon avatar TommyLemon commented on April 29, 2024

@Hugh0529
已支持自动化的 join。
例如
Moment INNER JOIN User LEFT JOIN Comment:

"[]":{
   "join": "&/User/id@,</Comment/momentId@",
   "Moment":{},
   "User":{
     "name?":"t",
     "id@": "/Moment/userId"
   },
   "Comment":{
     "momentId@": "/Moment/id"
   }
}

详情见 通用文档/3.2 功能符/数组关键词 中的 join,感谢支持^_^
https://github.com/TommyLemon/APIJSON/blob/master/Document.md#3.2

from apijson.

TommyLemon avatar TommyLemon commented on April 29, 2024

新增应用层连表 APP JOIN,例如 "join":"@/User/id@",支持跨不同类型数据库,缓存粒度更细更容易命中
https://github.com/TommyLemon/APIJSON/releases/tag/3.2.0

from apijson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.