开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 1 Fork 0

APIJSON/APIJSONdocs

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
APIJSONdocs
/
build
/
documentation
/
design_rules.html
APIJSONdocs
/
build
/
documentation
/
design_rules.html
design_rules.html 57.95 KB
一键复制 编辑 原始数据 按行查看 历史
Ruoran Wang 提交于 2020年01月17日 13:48 +08:00 . edit on how.rst
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API design style guide &mdash; APIJSON Docs 1.0.0 documentation</title>
<script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/language_data.js"></script>
<script type="text/javascript" src="../_static/contentui.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
<link rel="stylesheet" href="../_static/contentui.css" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="How does APIJSON works?" href="why.html" />
<link rel="prev" title="Client-side Deployment" href="../quick_start/client_deployment/client_deployment.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> APIJSON Docs
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Quick Start</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/introduction.html">About APIJSON</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/features.html">Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/server_deployment/server_deployment.html">Server-side Deployment</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quick_start/client_deployment/client_deployment.html">Client-side Deployment</a></li>
</ul>
<p class="caption"><span class="caption-text">Documentation</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">API design style guide</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#apijson-methods">1. APIJSON Methods</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#get"><strong>GET</strong> :</a></li>
<li class="toctree-l3"><a class="reference internal" href="#head"><strong>HEAD</strong> :</a></li>
<li class="toctree-l3"><a class="reference internal" href="#gets"><strong>GETS</strong> :</a></li>
<li class="toctree-l3"><a class="reference internal" href="#heads"><strong>HEADS</strong> :</a></li>
<li class="toctree-l3"><a class="reference internal" href="#post"><strong>POST</strong> :</a></li>
<li class="toctree-l3"><a class="reference internal" href="#put"><strong>PUT</strong> :</a></li>
<li class="toctree-l3"><a class="reference internal" href="#delete"><strong>DELETE</strong> :</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#functional-key-value-pairs">2. Functional Key-Value Pairs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#build-in-string-functions-part-one">3. Build-in string functions part one</a></li>
<li class="toctree-l2"><a class="reference internal" href="#build-in-string-functions-part-two">4. Build-in string functions part two</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="why.html">How does APIJSON works?</a></li>
<li class="toctree-l1"><a class="reference internal" href="what_achieved.html">What APIJSON has achieved?</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">APIJSON Docs</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li>API design style guide</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/documentation/design_rules.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="api-design-style-guide">
<h1>API design style guide<a class="headerlink" href="#api-design-style-guide" title="Permalink to this headline"></a></h1>
<p>This chapter introduces methods in APIJSON. These methods are:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 31%" />
<col style="width: 69%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#getdef"><span class="std std-ref">GET</span></a></p></td>
<td><p>It provides a general way to retrieve resources.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#headdef"><span class="std std-ref">HEAD</span></a></p></td>
<td><p>It provides a general way to count resources satisfying
specifics in the request body.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#getsdef"><span class="std std-ref">GETS</span></a></p></td>
<td><p>It requests for highly secured and confidential data
like bank accounts, birth dates.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#headsdef"><span class="std std-ref">HEADS</span></a></p></td>
<td><p>It’s used for getting counts of highly secured
resources(eg. bank accounts).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#postdef"><span class="std std-ref">POST</span></a></p></td>
<td><p>It creates new resources under the specified parent
resource(TableName).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#putdef"><span class="std std-ref">PUT</span></a></p></td>
<td><p>This method asks the server to update/edit an existing
resource.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#deletedef"><span class="std std-ref">DELETE</span></a></p></td>
<td><p>This method deletes the specified resource.</p></td>
</tr>
</tbody>
</table>
<p>Request method tells the server what kind of action the client wants the server to take. The method are also commonly referred to as the request "verb". This chapter will show you how these methods are included in url to send requests.</p>
<p>In the following explanations, the <em>base_URL</em> means the root URL. Everything that follows it is known as a URL path. All URL paths are relative to the base URL.</p>
<div class="section" id="apijson-methods">
<h2>1. APIJSON Methods<a class="headerlink" href="#apijson-methods" title="Permalink to this headline"></a></h2>
<div class="section" id="get">
<span id="getdef"></span><h3><strong>GET</strong> :<a class="headerlink" href="#get" title="Permalink to this headline"></a></h3>
<p>A general way to retrieve resources.</p>
<p><span class="blue">base_url/get/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="p">{</span>
<span class="s2">&quot;TableName&quot;</span><span class="p">{</span>
<span class="o">//</span> <span class="n">conditions</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="o">//</span> <span class="n">eg</span><span class="o">.</span> <span class="n">Request</span> <span class="n">a</span> <span class="n">post</span> <span class="k">with</span> <span class="nb">id</span> <span class="o">=</span> <span class="mi">235</span> <span class="ow">in</span> <span class="n">table</span> <span class="s2">&quot;Post&quot;</span><span class="p">:</span>
<span class="p">{</span>
<span class="s2">&quot;Post&quot;</span><span class="p">{</span>
<span class="s2">&quot;id&quot;</span><span class="p">:</span> <span class="mi">235</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span> {
&quot;TableName&quot;:{
...
},
&quot;code&quot;:200,
&quot;msg&quot;:"success"
}
// eg. The returned response:
{
&quot;Moment&quot;:{
&quot;id&quot;:235,
&quot;userId&quot;:38710,
&quot;content&quot;:&quot;...&quot;
},
&quot;code&quot;:200,
&quot;msg&quot;:&quot;success&quot;
}
</pre></div>
</div>
</div></blockquote>
</div>
</div>
</div>
<div class="section" id="head">
<span id="headdef"></span><h3><strong>HEAD</strong> :<a class="headerlink" href="#head" title="Permalink to this headline"></a></h3>
<p>A general way to count resources satisfying specifics in the request body.</p>
<p><span class="blue">base_url/head/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="s2">&quot;TableName&quot;</span><span class="p">:{</span>
<span class="o">//</span> <span class="n">conditions</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="o">//</span> <span class="n">eg</span><span class="o">.</span> <span class="n">Get</span> <span class="n">the</span> <span class="n">number</span> <span class="n">of</span> <span class="n">posts</span> <span class="n">posted</span> <span class="n">by</span> <span class="n">the</span> <span class="n">user</span> <span class="n">whose</span> <span class="nb">id</span> <span class="o">=</span> <span class="mi">38710</span><span class="p">:</span>
<span class="p">{</span>
<span class="s2">&quot;Post&quot;</span><span class="p">:{</span>
<span class="s2">&quot;userId&quot;</span><span class="p">:</span><span class="mi">38710</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="s2">&quot;TableName&quot;</span><span class="p">:{</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;count&quot;</span><span class="p">:</span><span class="o">...</span>
<span class="p">},</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
<span class="o">//</span> <span class="n">eg</span><span class="o">.</span>
<span class="p">{</span>
<span class="s2">&quot;Post&quot;</span><span class="p">:{</span><span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span> <span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span><span class="p">,</span> <span class="s2">&quot;count&quot;</span><span class="p">:</span><span class="mi">10</span><span class="p">},</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="gets">
<span id="getsdef"></span><h3><strong>GETS</strong> :<a class="headerlink" href="#gets" title="Permalink to this headline"></a></h3>
<p>Request for highly secured and confidential data like bank accounts, birth dates.</p>
<p><span class="blue">base_url/gets/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span>// You need to nest a key-value pair
"tag": tag
// at the top level of the request json object. The tag is usually the related table&#39;s name.
//Except that, the structure is the same as **GET**.
</pre></div>
</div>
</div></blockquote>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Same</span> <span class="k">as</span> <span class="o">**</span><span class="n">GET</span><span class="o">**</span>
</pre></div>
</div>
</div></blockquote>
</div>
</div>
</div>
<div class="section" id="heads">
<span id="headsdef"></span><h3><strong>HEADS</strong> :<a class="headerlink" href="#heads" title="Permalink to this headline"></a></h3>
<p>It’s used for getting counts of highly secured resources(eg. bank accounts).</p>
<p><span class="blue">base_url/heads/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>// You need to nest a key-value pair
"tag": tag
// at the top level of the request json object.
//Except that, the structure is the same as **HEAD**.
</pre></div>
</div>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span>// Same as **HEAD**.
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="post">
<span id="postdef"></span><h3><strong>POST</strong> :<a class="headerlink" href="#post" title="Permalink to this headline"></a></h3>
<p>The <strong>POST</strong> method creates new resources under the specified parent resource(TableName).</p>
<p><span class="blue">base_url/post/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>{
&quot;TableName&quot;:{...
},
&quot;tag&quot;:tag
}
// Note the id in the object &quot;TableName&quot;:{...} has been generated automatically when table is built and can’t be set by the user here.
// eg. A user with id = 38710 posts a new post:
{
&quot;Post&quot;:{
&quot;userId&quot;:38710,
&quot;content&quot;:&quot;APIJSON lets interfaces and documents go hell!&quot;
},
&quot;tag&quot;:&quot;Moment&quot;
}
</pre></div>
</div>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="p">{</span>
<span class="s2">&quot;Moment&quot;</span><span class="p">:{</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="o">...</span>
<span class="p">},</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
<span class="o">//</span> <span class="n">If</span> <span class="n">the</span> <span class="n">request</span> <span class="ow">is</span> <span class="n">successful</span><span class="p">,</span> <span class="n">it</span> <span class="n">should</span> <span class="k">return</span> <span class="n">following</span> <span class="nb">object</span><span class="o">.</span>
<span class="p">{</span>
<span class="n">TableName</span><span class="p">:{</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">38710</span>
<span class="p">},</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="put">
<span id="putdef"></span><h3><strong>PUT</strong> :<a class="headerlink" href="#put" title="Permalink to this headline"></a></h3>
<p>The <strong>PUT</strong> method asks the server to update/edit an existing resource. The part that will be modified is included in the request body.</p>
<p><span class="blue">base_url/put/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> {
&quot;TableName&quot;:{
&quot;id&quot;:id,
...
},
&quot;tag&quot;:tag
}
// You need to either specify the id in the TableName object like the example above or add a id{} object in the request body.
// The following example makes request to update the content made by id = 235:
{
&quot;Post&quot;:{
&quot;id&quot;:235,
&quot;content&quot;:&quot;APIJSON lets interfaces and documents go hell !&quot;
},
&quot;tag&quot;:&quot;Post&quot;
}
</pre></div>
</div>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<blockquote>
<div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>\\ Same as **POST**.
</pre></div>
</div>
</div></blockquote>
</div>
</div>
</div>
<div class="section" id="delete">
<span id="deletedef"></span><h3><strong>DELETE</strong> :<a class="headerlink" href="#delete" title="Permalink to this headline"></a></h3>
<p>The <strong>DELETE</strong> method deletes the specified resource.</p>
<p><span class="blue">base_url/delete/</span></p>
<div class="content-tabs docutils container">
<div class="tab-content docutils container" id="tab-tab1">
<p class="tab-title">Request</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="n">TableName</span><span class="p">:{</span>
<span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="nb">id</span>
<span class="p">},</span>
<span class="s2">&quot;tag&quot;</span><span class="p">:</span><span class="n">tag</span>
<span class="p">}</span>
<span class="o">//</span> <span class="n">You</span> <span class="n">need</span> <span class="n">to</span> <span class="n">either</span> <span class="n">specify</span> <span class="n">the</span> <span class="nb">id</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">TableName</span> <span class="nb">object</span> <span class="n">like</span> <span class="n">the</span> <span class="n">example</span> <span class="n">above</span> <span class="ow">or</span> <span class="n">add</span> <span class="n">a</span> <span class="nb">id</span><span class="p">{}</span> <span class="nb">object</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">request</span> <span class="n">body</span><span class="o">.</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">following</span> <span class="n">example</span> <span class="n">send</span> <span class="n">a</span> <span class="n">request</span> <span class="n">to</span> <span class="n">delete</span> <span class="n">comments</span> <span class="n">made</span> <span class="n">by</span> <span class="nb">id</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">,</span><span class="mi">120</span>
<span class="p">{</span>
<span class="s2">&quot;Comment&quot;</span><span class="p">:{</span>
<span class="s2">&quot;id</span><span class="si">{}</span><span class="s2">&quot;</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">,</span><span class="mi">120</span><span class="p">]</span>
<span class="p">},</span>
<span class="s2">&quot;tag&quot;</span><span class="p">:</span><span class="s2">&quot;Comment[]&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="tab-content docutils container" id="tab-tab2">
<p class="tab-title">Response</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="p">{</span>
<span class="s2">&quot;TableName&quot;</span><span class="p">:{</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;id[]&quot;</span><span class="p">:[</span><span class="o">...</span><span class="p">]</span>
<span class="s2">&quot;count&quot;</span><span class="p">:</span><span class="mi">3</span>
<span class="p">},</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
<span class="o">//</span> <span class="n">The</span> <span class="n">response</span> <span class="n">to</span> <span class="n">the</span> <span class="n">request</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">example</span> <span class="n">above</span>
<span class="p">{</span>
<span class="s2">&quot;Comment&quot;</span><span class="p">:{</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span><span class="p">,</span>
<span class="s2">&quot;id[]&quot;</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="mi">110</span><span class="p">,</span><span class="mi">120</span><span class="p">],</span>
<span class="s2">&quot;count&quot;</span><span class="p">:</span><span class="mi">3</span>
<span class="p">},</span>
<span class="s2">&quot;code&quot;</span><span class="p">:</span><span class="mi">200</span><span class="p">,</span>
<span class="s2">&quot;msg&quot;</span><span class="p">:</span><span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<p><strong>Note:</strong></p>
<blockquote>
<div><ol class="arabic simple">
<li><p><em>TableName</em> means the name of the table that a user interacts with. It’s a string with the first letter capitalized. It can be any combination of letters, numbers and underscores. As a key, its value is a jsonObject which may include columns’ names in the table.</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">"tag":tag</span></code> needs to be included when the request method is neither <strong>GET</strong> nor <strong>HEAD</strong>. The value <em>tag</em> is the key of the returned jsonObject in the response body. Usually, it’s the name of the related table.</p></li>
<li><p>The request form under <strong>GET</strong> and <strong>HEAD</strong> methods are very flexible. The request jsonObject can be nested many levels. However, other methods need to be constrained by adding tags, etc. The structure of the request body needs to conform resources at the backend.</p></li>
<li><p><strong>GETS</strong> and <strong>GET</strong>, <strong>HEADS</strong> and <strong>HEAD</strong> are the same type of operation. For both groups, the request bodies have something different, while the response bodies are the same.</p></li>
<li><p>When transmit through HTTP protocal, all the API methods (get,gets,head,heads,post,put,delete) use HTTP <strong>POST</strong> verb.</p></li>
<li><p>All jsonObjects are seen as variables or folders with the form of <code class="code docutils literal notranslate"><span class="pre">{...}</span></code>. It can store objects or associative arrays.</p></li>
<li><p>Each object is related to an individually-addressable resource which has an unique address.</p></li>
</ol>
</div></blockquote>
</div>
</div>
<div class="section" id="functional-key-value-pairs">
<h2>2. Functional Key-Value Pairs<a class="headerlink" href="#functional-key-value-pairs" title="Permalink to this headline"></a></h2>
<p><strong>Get data in an array:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{&quot;key[]&quot;:{&quot;tableName&quot;:{}}}</span></code></p>
<p>The part after the colon is a JSONObject. The <code class="code docutils literal notranslate"><span class="pre">key</span></code> is optional. When <code class="code docutils literal notranslate"><span class="pre">key</span></code> is as the same as the <code class="code docutils literal notranslate"><span class="pre">tableName</span></code>, the JSONObject will be in a simplified form. For example: <code class="code docutils literal notranslate"><span class="pre">{&quot;User[]&quot;:{&quot;User&quot;:{&quot;id&quot;,...}}}</span></code> will be written as <code class="code docutils literal notranslate"><span class="pre">{&quot;User[]&quot;:{&quot;id&quot;,...}}</span></code>.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%7D%7D%7D">/get/{"User[]":{"count":3,"User":{}}}</a></p>
<p>In this example, the request is to <strong>GET</strong> 3 users’ information. The response includes 3 users information with all categories saved in an array.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Get filtered data:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{&quot;key[]&quot;:{&quot;tableName&quot;:{&quot;key2{}&quot;:[]}}}</span></code></p>
<p>Specifically in this part: <code class="code docutils literal notranslate"><span class="pre">&quot;key2{}&quot;:[]</span></code>, the part after the colon is a JSONArray which contains <code class="code docutils literal notranslate"><span class="pre">key2</span></code>’s values. This part is to specify the conditions that the return should satisfy.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22id%7B%7D%22:%5B38710,82001,70793%5D%7D%7D%7D">/get/{"User[]":{"count":3,"User":{"id{}":[38710,82001,70793]}}}</a></p>
<p>This example shows how to get users’s information with id equals 38710,82001,70793.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Get data with comparison operation:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{&quot;key[]&quot;:{&quot;tableName&quot;:{&quot;id{}&quot;:&quot;&lt;=80000,&gt;90000&quot;}}}</span></code></p>
<p>Just as the comparison operation functions in SQL, it’s used here to get resources in a range. It dosn’t need to be numbers though.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22id%7B%7D%22:%22%3C=80000,%3E90000%22%7D%7D%7D">/get/{"User[]":{"count":3,"User":{"id{}":"&lt;=80000,&gt;90000"}}}</a></p>
<p>In SQL, it’d be <code class="code docutils literal notranslate"><span class="pre">id&lt;=80000</span> <span class="pre">OR</span> <span class="pre">id&gt;90000</span></code>, which means get User array with id&lt;=80000 | id&gt;90000</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Get data that contains an element:</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{&quot;key[]&quot;:{&quot;User&quot;:{&quot;key2&lt;&gt;&quot;:[object]}}}</span></code></p>
<p>This also used when the user wants to get data that meets specific conditions. <code class="code docutils literal notranslate"><span class="pre">key2</span></code> must be a JSONArray while <code class="code docutils literal notranslate"><span class="pre">object</span></code> cannot be JSON.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22contactIdList%3C%3E%22:38710%7D%7D%7D">"/get/{"User[]":{"count":3,"User":{"contactIdList&lt;&gt;":38710}}}":38710</a></p>
<p>In this example, it requests 3 User arrays whose contactIdList contains 38710. In SQL, this would be <code class="code docutils literal notranslate"><span class="pre">json_contains(contactIdList,38710)</span></code>.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>See if it exists</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{&quot;key&quot;:{&quot;key2}{&#64;&quot;:{&quot;from&quot;:&quot;tableName&quot;,&quot;tableName&quot;:{...}}}}</span></code></p>
<p>In this request url, <em>}{</em> means EXISTS; <em>key2</em> is the item you want to check.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><dl class="simple">
<dt><a href="#id1"><span class="problematic" id="id2">`</span></a>{"User":</dt><dd><dl class="simple">
<dt>{"id}{&#64;":{</dt><dd><p>"from":"Comment",
"Comment":{"momentId":15}
}
}
} &lt;<a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22id%7D%7B&#64;%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22momentId%22:15%7D%7D%7D%7D">http://apijson.cn:8080/get/%7B%22User%22:%7B%22id%7D%7B&#64;%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22momentId%22:15%7D%7D%7D%7D</a>&gt;`_</p>
</dd>
</dl>
</dd>
</dl>
<p>In this example, the request is to check if the id whose <code class="code docutils literal notranslate"><span class="pre">momentId</span> <span class="pre">=</span> <span class="pre">15</span></code> exists. The SQL form would be <code class="code docutils literal notranslate"><span class="pre">WHERE</span> <span class="pre">EXISTS(SELECT</span> <span class="pre">*</span> <span class="pre">FROM</span> <span class="pre">Comment</span> <span class="pre">WHERE</span> <span class="pre">momentId=15)</span></code></p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Include functions in url parameters</strong> <code class="code docutils literal notranslate"><span class="pre">/get/{&quot;Table&quot;:{&quot;key&quot;:value,</span> <span class="pre">key()&quot;:&quot;function</span> <span class="pre">(key0,key1...)}&quot;</span></code></p>
<p>This will trigger the back-end function(JSONObject request, String key0, String key1...)to get or testify data.</p>
<p>Use - and + to show the order of priority: analyze key-() &gt; analyze the current object &gt; analyze key() &gt; analyze child object &gt; analyze key+()</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22Moment%22:%7B%22id%22:301,%22isPraised()%22:%22isContain(praiseUserIdList,userId)%22%7D%7D">/get/{"Moment":{"id":301,"isPraised()":"isContain(praiseUserIdList,userId)"}}</a></p>
<p>This will use function boolean <code class="code docutils literal notranslate"><span class="pre">isContain(JSONObject</span> <span class="pre">request,</span> <span class="pre">String</span> <span class="pre">array,</span> <span class="pre">String</span> <span class="pre">value)</span></code>. In this case, client will get <code class="code docutils literal notranslate"><span class="pre">"is</span> <span class="pre">praised":</span> <span class="pre">true</span></code> (In this case, client use function to testify if a user clicked ‘like’ button for a post.)</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Refer a value</strong></p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span>&quot;key@&quot;:&quot;key0/key1/.../refKey&quot;
</pre></div>
</div>
<p>Use forward slash to show the path. The part before the colon is the key that wants to refer. The path after the colon starts with the parent level of the key.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><dl>
<dt><a href="#id3"><span class="problematic" id="id4">`</span></a>"Moment":{</dt><dd><blockquote>
<div><p>"userId":38710
},</p>
</div></blockquote>
<dl class="simple">
<dt>"User":{</dt><dd><p>"id&#64;":"/Moment/userId"
} &lt;<a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22id&#64;%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22&#64;column%22:%22min(userId)%22%7D%7D%7D%7D">http://apijson.cn:8080/get/%7B%22User%22:%7B%22id&#64;%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22&#64;column%22:%22min(userId)%22%7D%7D%7D%7D</a>&gt;`_</p>
</dd>
</dl>
</dd>
</dl>
<p>In this example, the value of <code class="code docutils literal notranslate"><span class="pre">id</span></code> in <code class="code docutils literal notranslate"><span class="pre">User</span></code> refer to the <code class="code docutils literal notranslate"><span class="pre">userId</span></code> in <code class="code docutils literal notranslate"><span class="pre">Moment</span></code>, which means <code class="code docutils literal notranslate"><span class="pre">User.id</span> <span class="pre">=</span> <span class="pre">Moment.userId</span></code>. After the request is sent, <code class="code docutils literal notranslate"><span class="pre">&quot;id&#64;&quot;:&quot;/Moment/userId&quot;</span></code> will be <code class="code docutils literal notranslate"><span class="pre">&quot;id&quot;:38710</span></code>.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Subquery expression</strong></p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span>&quot;key@&quot;:{
&quot;range&quot;: &quot;ALL&quot;,
&quot;from&quot;:&quot;Table&quot;,
&quot;Table&quot;:{ ... }
}
</pre></div>
</div>
<p>Range can be <strong>ALL</strong>, <strong>ANY</strong>. It means which table you want to query. It’s very similar to how you query in SQL. You can also use <strong>COUNT</strong>, <strong>JOIN</strong>, etc.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><dl>
<dt><a href="#id5"><span class="problematic" id="id6">`</span></a>"id&#64;":{</dt><dd><p>"from":"Comment",
"Comment":{
"&#64;column":"min(userId)"</p>
<blockquote>
<div><p>}</p>
</div></blockquote>
<p>} &lt;<a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22id&#64;%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22&#64;column%22:%22min(userId)%22%7D%7D%7D%7D">http://apijson.cn:8080/get/%7B%22User%22:%7B%22id&#64;%22:%7B%22from%22:%22Comment%22,%22Comment%22:%7B%22&#64;column%22:%22min(userId)%22%7D%7D%7D%7D</a>&gt;`_</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">code</dt>
<dd class="field-odd"><p><cite>WHERE id=(SELECT min(userId) FROM Comment)</cite></p>
</dd>
</dl>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Fuzzy matching</strong> <code class="code docutils literal notranslate"><span class="pre">&quot;key$&quot;:&quot;SQL</span> <span class="pre">search</span> <span class="pre">expressions&quot;</span></code> =&gt; <code class="code docutils literal notranslate"><span class="pre">&quot;key$&quot;:[&quot;SQL</span> <span class="pre">search</span> <span class="pre">expressions&quot;]</span></code></p>
<p>Any SQL search expression can be applied here.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22name$%22:%22%2525m%2525%22%7D%7D%7D">"name$":"%m%"</a></p>
<p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">name</span> <span class="pre">LIKE</span> <span class="pre">'%m%'</span></code>, meaning that get <em>User</em> with ‘m’ in name.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Regular Expression</strong> <code class="code docutils literal notranslate"><span class="pre">&quot;key~&quot;:&quot;regular</span> <span class="pre">expression&quot;</span></code> =&gt; <code class="code docutils literal notranslate"><span class="pre">&quot;key~&quot;:[&quot;regular</span> <span class="pre">expression&quot;]</span></code></p>
<p>It can be any regular expressions. Advanced search is applicable.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22name~%22:%22%5E%5B0-9%5D%252B$%22%7D%7D%7D">"name~":"^[0-9]+$"</a></p>
<p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">name</span> <span class="pre">REGEXP</span> <span class="pre">'^[0-9]+$'</span></code>.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Get data in a range</strong> <code class="code docutils literal notranslate"><span class="pre">&quot;key%&quot;:&quot;start,end&quot;</span></code> =&gt; <code class="code docutils literal notranslate"><span class="pre">&quot;key%&quot;:[&quot;start,end&quot;]</span></code></p>
<p>The data type of start and end can only be either <strong>Boolean</strong>, <strong>Number</strong> or <strong>String</strong>. Eg. "2017年01月01日,2019年01月01日", ["1,90000", "82001,100000"]. It’s used for getting data from a specific time range.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:3,%22User%22:%7B%22date%2525%22:%222017-10-01,2018年10月01日%22%7D%7D%7D">"date%":"2017年10月01日,2018年10月01日"</a></p>
<blockquote>
<div><p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">date</span> <span class="pre">BETWEEN</span> <span class="pre">'2017-10-01'</span> <span class="pre">AND</span> <span class="pre">'2018-10-01'</span></code>, meaning to get <em>User</em> data that registered between 2017年10月01日 and 2018年10月01日.</p>
</div></blockquote>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Make an alias</strong> <code class="code docutils literal notranslate"><span class="pre">&quot;name:alias&quot;</span></code></p>
<p>This changes name to alias in returning results. It’s applicable to column, tableName, SQL Functions, etc. but only in GET, HEAD requests.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22Comment%22:%7B%22&#64;column%22:%22id,toId:parentId%22,%22id%22:51%7D%7D">/get/{"Comment":{"&#64;column":"id,toId:parentId","id":51}}</a></p>
<p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">toId</span> <span class="pre">AS</span> <span class="pre">parentId</span></code>. It’ll return <em>parentID</em> instead of <em>toID</em>.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Add / expand an item</strong> <code class="code docutils literal notranslate"><span class="pre">&quot;key+&quot;:number/string/array...</span></code></p>
<p>The type of value on the right of the colon is decided by key. Types can be <strong>Number</strong> (such as 82001), <strong>String</strong> (such as "url0"), <strong>JSONArray</strong> (such as ["url0","url1"]). The method can only be <strong>PUT</strong>.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><dl class="field-list simple">
<dt class="field-odd">code</dt>
<dd class="field-odd"><p><cite>"praiseUserIdList+":[82001]</cite></p>
</dd>
</dl>
<p>In this example, add id 82001 to the praiser’s list. In SQL, it should be <code class="code docutils literal notranslate"><span class="pre">json_insert(praiseUserIdList,82001)</span></code>.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Delete / decrease an item</strong> <code class="code docutils literal notranslate"><span class="pre">"Key-":number/string/array...</span></code></p>
<p>It has the contrary function of <code class="code docutils literal notranslate"><span class="pre">"key+"</span></code>.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><code class="code docutils literal notranslate"><span class="pre">&quot;balance-&quot;:100.00</span></code></p>
<p>This example subtract 100 in the balance. In SQL, it would be <code class="code docutils literal notranslate"><span class="pre">balance</span> <span class="pre">=</span> <span class="pre">balance</span> <span class="pre">-</span> <span class="pre">100.00</span></code>.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p><strong>Logical Operators</strong> <code class="code docutils literal notranslate"><span class="pre">&amp;,|,!</span></code></p>
<p><code class="code docutils literal notranslate"><span class="pre">&amp;,|,!</span></code> refer to <strong>AND</strong>, <strong>OR</strong>, <strong>NOT</strong> in SQL respectively. The basic form to use them are: <code class="code docutils literal notranslate"><span class="pre">&quot;key&amp;{}&quot;:&quot;conditions&quot;</span></code>, <code class="code docutils literal notranslate"><span class="pre">&quot;key|{}&quot;:&quot;conditions&quot;</span></code>, <code class="code docutils literal notranslate"><span class="pre">&quot;key!{}&quot;:Object</span></code>.</p>
<p>By default, conditions of the same key are connected with <code class="code docutils literal notranslate"><span class="pre">|</span></code> operator. As for different <code class="code docutils literal notranslate"><span class="pre">&quot;key&quot;:&quot;conditons&quot;`pairs,</span> <span class="pre">the</span> <span class="pre">default</span> <span class="pre">operator</span> <span class="pre">among</span> <span class="pre">them</span> <span class="pre">is</span> <span class="pre">:code:`&amp;</span></code>.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p>1 <a class="reference external" href="http://apijson.cn:8080/head/%7B%22User%22:%7B%22id&amp;%7B%7D%22:%22%3E80000,%3C=90000%22%7D%7D">/head/{"User":{"id&amp;{}":"&gt;80000,&lt;=90000"}}</a></p>
<p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">id&gt;80000</span> <span class="pre">AND</span> <span class="pre">id&lt;=90000</span></code>, meaning id needs to be <code class="code docutils literal notranslate"><span class="pre">id&gt;80000</span> <span class="pre">&amp;</span> <span class="pre">id&lt;=90000</span></code></p>
<p>2 <a class="reference external" href="http://apijson.cn:8080/head/%7B%22User%22:%7B%22id%7C%7B%7D%22:%22%3E90000,%3C=80000%22%7D%7D">/head/{"User":{"id|{}":"&gt;90000,&lt;=80000"}}</a>.</p>
<p>It’s the same as <code class="code docutils literal notranslate"><span class="pre">&quot;id{}&quot;:&quot;&gt;90000,&lt;=80000&quot;</span></code>. In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">id&gt;80000</span> <span class="pre">OR</span> <span class="pre">id&lt;=90000</span></code>, meaning that id needs to be <code class="code docutils literal notranslate"><span class="pre">id&gt;90000</span> <span class="pre">|</span> <span class="pre">id&lt;=80000</span></code>.</p>
<p>3 <a class="reference external" href="http://apijson.cn:8080/head/%7B%22User%22:%7B%22id!%7B%7D%22:%5B82001,38710%5D%7D%7D">/head/{"User":{"id!{}":[82001,38710]}}</a>.</p>
<p>In SQL, it’s <code class="code docutils literal notranslate"><span class="pre">id</span> <span class="pre">NOT</span> <span class="pre">IN(82001,38710)</span></code>, meaning <code class="code docutils literal notranslate"><span class="pre">id</span></code> needs to be <code class="code docutils literal notranslate"><span class="pre">!</span> <span class="pre">(id=82001</span> <span class="pre">|</span> <span class="pre">id=38710)</span></code>.</p>
</div></blockquote>
</div>
</div>
<hr class="docutils" />
<div class="section" id="build-in-string-functions-part-one">
<h2>3. Build-in string functions part one<a class="headerlink" href="#build-in-string-functions-part-one" title="Permalink to this headline"></a></h2>
<p>1 <code class="code docutils literal notranslate"><span class="pre">&quot;count&quot;:Integer</span></code></p>
<p>This is used to set the maximum number of the returning resources. The maximum number the system supports is 100. Without this, it’ll return the maximum number of results that meet the condition.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:5,%22User%22:%7B%7D%7D%7D">/get/{"[]":{"count":5,"User":{}}}</a></p>
<p>This example requests 5 Users’ data.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>2 <code class="code docutils literal notranslate"><span class="pre">&quot;page&quot;:Integer</span></code></p>
<p>This is to indicate the page number starting with 0. The max number can be 100. It’s usually used with <code class="code docutils literal notranslate"><span class="pre">&quot;count&quot;:Integer</span></code></p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:5,%22page%22:3,%22User%22:%7B%7D%7D%7D">/get/{"[]":{"count":5,"page":3,"User":{}}}</a></p>
<p>This example get Users data on page 3 with the total number of 5.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>3 <code class="code docutils literal notranslate"><span class="pre">&quot;query&quot;:Integer</span></code></p>
<p>When the <code class="code docutils literal notranslate"><span class="pre">Integer</span></code> is 0, it means get the resource. When it’s 1, it means counting the number and returning the number.When it’s 2, it means returning both.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22query%22:2,%22count%22:5,%22User%22:%7B%7D%7D,%22total&#64;%22:%22%252F%5B%5D%252Ftotal%22%7D">/get/{"[]":{"query":2, User:{}}, "total&#64;":"/[]/total"}</a></p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>4 <code class="code docutils literal notranslate"><span class="pre">&quot;join&quot;:&quot;&amp;/Table0/key0&#64;,&lt;/Table1/key1&#64;&quot;</span></code></p>
<p>The joining table functions are represented by symbols:</p>
<p>"&lt;" - LEFT JOIN</p>
<p>"&gt;" - RIGHT JOIN</p>
<p>"&amp;" - INNER JOIN</p>
<p>"|" - FULL JOIN</p>
<p>"!" - OUTTER JOIN</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:5,%22join%22:%22&amp;%252FUser%252Fid&#64;,%3C%252FComment%252FmomentId&#64;%22,%22Moment%22:%7B%22&#64;column%22:%22id,userId,content%22%7D,%22User%22:%7B%22name%253F%22:%22t%22,%22id&#64;%22:%22%252FMoment%252FuserId%22,%22&#64;column%22:%22id,name,head%22%7D,%22Comment%22:%7B%22momentId&#64;%22:%22%252FMoment%252Fid%22,%22&#64;column%22:%22id,momentId,content%22%7D%7D%7D">/get/{"[]":{"join": "&amp;/User/id&#64;,&lt;/Comment/momentId&#64;", "Moment":{}, "User":{"name?":"t", "id&#64;": "/Moment/userId"}, "Comment":{"momentId&#64;": "/Moment/id"}}}</a></p>
</div></blockquote>
<p>This examples is equal to SQL expression <code class="code docutils literal notranslate"><span class="pre">Moment</span> <span class="pre">INNER</span> <span class="pre">JOIN</span> <span class="pre">User</span> <span class="pre">LEFT</span> <span class="pre">JOIN</span> <span class="pre">Comment</span></code>.</p>
</div></blockquote>
</div>
</div>
<hr class="docutils" />
<div class="section" id="build-in-string-functions-part-two">
<h2>4. Build-in string functions part two<a class="headerlink" href="#build-in-string-functions-part-two" title="Permalink to this headline"></a></h2>
<p>1 <code class="code docutils literal notranslate"><span class="pre">&quot;&#64;combine&quot;:&quot;&amp;key0,&amp;key1,|key2,key3,!key4,!key5,&amp;key6,key7...&quot;</span></code></p>
<p>This function combines conditions that have been listed to request data. It’ll group conditions according to their types. It uses logical operators(&amp;,|,!) to connect among groups while within a group, it’ll follow the order that conditions have been listed. So, it’ll become :code:<a href="#id7"><span class="problematic" id="id8">`</span></a>(key0 &amp; key1 &amp; key6 &amp; other keys) &amp; (key2 | key3 | key7) &amp; !(key4 | key5) `</p>
<p>The:code:<cite>other keys</cite> means keys that aren’t included in <code class="code docutils literal notranslate"><span class="pre">combine</span></code> function. By default, it’s connected by AND.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%5B%5D%22:%7B%22count%22:10,%22User%22:%7B%22&#64;column%22:%22id,name,tag%22,%22name~%22:%22a%22,%22tag~%22:%22a%22,%22&#64;combine%22:%22name~,tag~%22%7D%7D%7D">/get/{"User[]":{"count":10,"User":{"&#64;column":"id,name,tag","name~":"a","tag~":"a","&#64;combine":"name~,tag~"}}}</a></p>
<p>This example request User objects whose <code class="code docutils literal notranslate"><span class="pre">name</span></code> or <code class="code docutils literal notranslate"><span class="pre">tag</span></code> includes "a".</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>2 <code class="code docutils literal notranslate"><span class="pre">&quot;&#64;column&quot;:&quot;column;function(arg)...&quot;</span></code></p>
<p>This function defines which colunms will be returned.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22User%22:%7B%22&#64;column%22:%22id,sex,name%22,%22id%22:38710%7D%7D">/get/{"User":{"&#64;column":"id,sex,name","id":38710}}</a></p>
<p>This request only returns colunms: id, sex, name. The returning follows the same order.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>3 <code class="code docutils literal notranslate"><span class="pre">&quot;&#64;order&quot;:&quot;column0+,column1-...&quot;</span></code></p>
<p>This function can set descendent or ascendent order of returning data within a column.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:10,%22User%22:%7B%22&#64;column%22:%22name,id%22,%22&#64;order%22:%22name-,id%22%7D%7D%7D">/get/{"[]":{"count":10,"User":{"&#64;column":"name,id","&#64;order":"name-,id"}}}</a></p>
<p>This example requests data following descendent order in name column while the default order in id column.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>4 <code class="code docutils literal notranslate"><span class="pre">&quot;&#64;group&quot;:&quot;column0,column1...&quot;</span></code></p>
<p>This function groups data with columns. If the table’s <code class="code docutils literal notranslate"><span class="pre">id</span></code> has been declared in <code class="code docutils literal notranslate"><span class="pre">&#64;column</span></code>, then the <code class="code docutils literal notranslate"><span class="pre">id</span></code> needs to be included in <code class="code docutils literal notranslate"><span class="pre">&#64;group</span></code>.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:10,%22Moment%22:%7B%22&#64;column%22:%22userId,id%22,%22&#64;group%22:%22userId,id%22%7D%7D%7D">/get/{"[]":{"count":10,"Moment":{"&#64;column":"userId,id","&#64;group":"userId,id"}}}</a></p>
<p>This example returns <code class="code docutils literal notranslate"><span class="pre">id</span></code> grouped by userId.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>5 <code class="code docutils literal notranslate"><span class="pre">&quot;&#64;having&quot;:&quot;function0(...)?value0;function1(...)?value1;function2(...)?value2...&quot;</span></code></p>
<p>This function is as same as the <strong>HAVING</strong> function in AQL. Normally, it’s used with <code class="code docutils literal notranslate"><span class="pre">&#64;group</span></code>.</p>
<div class="toggle-header docutils container">
<p>Example</p>
</div>
<div class="toggle-content docutils container">
<blockquote>
<div><p><a class="reference external" href="http://apijson.cn:8080/get/%7B%22%5B%5D%22:%7B%22count%22:10,%22Moment%22:%7B%22&#64;column%22:%22userId%253Bmax(id)%22,%22&#64;group%22:%22userId%22,%22&#64;having%22:%22max(id)%3E=100%22%7D%7D%7D">/get/{"[]":{"Moment":{"&#64;column":"userId;max(id)","&#64;group":"userId","&#64;having":"max(id)&gt;=100"}}}</a></p>
<p>This example get an array of Moment with userID and id where id &gt;=100, grouped by userId.</p>
</div></blockquote>
</div>
<hr class="docutils" />
<p>6 <code class="code docutils literal notranslate"><span class="pre">&quot;&#64;schema&quot;:&quot;sys&quot;</span></code></p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="why.html" class="btn btn-neutral float-right" title="How does APIJSON works?" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../quick_start/client_deployment/client_deployment.html" class="btn btn-neutral float-left" title="Client-side Deployment" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2019, Ruoran Wang
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

The English APIJSON documentation. Forked from the original Repositry:
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/APIJSON/APIJSONdocs.git
git@gitee.com:APIJSON/APIJSONdocs.git
APIJSON
APIJSONdocs
APIJSONdocs
master
点此查找更多帮助

搜索帮助

仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /